├── .gitignore
├── LICENSE
├── README.md
├── ko-arahansa
├── README.md
├── part1
│ ├── README.md
│ ├── css-extract
│ │ ├── README.md
│ │ ├── package.json
│ │ ├── src
│ │ │ ├── changeColor.js
│ │ │ ├── index.html
│ │ │ ├── index.js
│ │ │ └── styles.css
│ │ ├── webpack.config.dev.js
│ │ └── webpack.config.prod.js
│ ├── example1
│ │ ├── README.md
│ │ ├── package.json
│ │ ├── src
│ │ │ ├── APIStuff.js
│ │ │ ├── UIStuff.js
│ │ │ ├── extraFile.js
│ │ │ ├── index.js
│ │ │ └── styles.css
│ │ └── webpack.config.js
│ ├── example2
│ │ ├── README.md
│ │ ├── package.json
│ │ ├── src
│ │ │ └── index.js
│ │ └── webpack.config.js
│ ├── example3
│ │ ├── README.md
│ │ ├── package.json
│ │ ├── src
│ │ │ └── index.js
│ │ └── webpack.config.js
│ ├── example4
│ │ ├── README.md
│ │ ├── package.json
│ │ ├── src
│ │ │ ├── index.html
│ │ │ ├── index.js
│ │ │ └── styles.css
│ │ └── webpack.config.js
│ ├── example5
│ │ ├── README.md
│ │ ├── package.json
│ │ ├── src
│ │ │ ├── index.html
│ │ │ ├── index.js
│ │ │ └── styles.css
│ │ └── webpack.config.js
│ ├── example6
│ │ ├── README.md
│ │ ├── package.json
│ │ ├── src
│ │ │ ├── index.html
│ │ │ ├── index.js
│ │ │ └── styles.css
│ │ ├── webpack.config.dev.js
│ │ └── webpack.config.prod.js
│ ├── example7
│ │ ├── README.md
│ │ ├── package.json
│ │ ├── src
│ │ │ ├── index.html
│ │ │ ├── index.js
│ │ │ └── styles.css
│ │ ├── webpack.config.dev.js
│ │ └── webpack.config.prod.js
│ └── html-reload
│ │ ├── README.md
│ │ ├── package.json
│ │ ├── src
│ │ ├── index.html
│ │ ├── index.js
│ │ └── styles.css
│ │ ├── webpack.config.dev.js
│ │ └── webpack.config.prod.js
└── part2
│ ├── README.md
│ └── example1
│ ├── .babelrc
│ ├── .eslintrc
│ ├── package.json
│ ├── src
│ ├── index.html
│ ├── index.js
│ └── styles.css
│ ├── webpack.config.dev.js
│ └── webpack.config.prod.js
├── part1
├── README.md
├── css-extract
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ ├── changeColor.js
│ │ ├── index.html
│ │ ├── index.js
│ │ └── styles.css
│ ├── webpack.config.dev.js
│ └── webpack.config.prod.js
├── example1
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ ├── APIStuff.js
│ │ ├── UIStuff.js
│ │ ├── extraFile.js
│ │ ├── index.js
│ │ └── styles.css
│ └── webpack.config.js
├── example2
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ └── index.js
│ └── webpack.config.js
├── example3
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ └── index.js
│ └── webpack.config.js
├── example4
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ ├── index.html
│ │ ├── index.js
│ │ └── styles.css
│ └── webpack.config.js
├── example5
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ ├── index.html
│ │ ├── index.js
│ │ └── styles.css
│ └── webpack.config.js
├── example6
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ ├── index.html
│ │ ├── index.js
│ │ └── styles.css
│ ├── webpack.config.dev.js
│ └── webpack.config.prod.js
├── example7
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ ├── index.html
│ │ ├── index.js
│ │ └── styles.css
│ ├── webpack.config.dev.js
│ └── webpack.config.prod.js
└── html-reload
│ ├── README.md
│ ├── package.json
│ ├── src
│ ├── index.html
│ ├── index.js
│ └── styles.css
│ ├── webpack.config.dev.js
│ └── webpack.config.prod.js
├── part2
├── README.md
└── example1
│ ├── .babelrc
│ ├── .eslintrc
│ ├── package.json
│ ├── src
│ ├── index.html
│ ├── index.js
│ └── styles.css
│ ├── webpack.config.dev.js
│ └── webpack.config.prod.js
├── zh-TW
├── README.md
├── part1
│ ├── README.md
│ ├── css-extract
│ │ ├── README.md
│ │ ├── package.json
│ │ ├── src
│ │ │ ├── changeColor.js
│ │ │ ├── index.html
│ │ │ ├── index.js
│ │ │ └── styles.css
│ │ ├── webpack.config.dev.js
│ │ └── webpack.config.prod.js
│ ├── example1
│ │ ├── README.md
│ │ ├── package.json
│ │ ├── src
│ │ │ ├── APIStuff.js
│ │ │ ├── UIStuff.js
│ │ │ ├── extraFile.js
│ │ │ ├── index.js
│ │ │ └── styles.css
│ │ └── webpack.config.js
│ ├── example2
│ │ ├── README.md
│ │ ├── package.json
│ │ ├── src
│ │ │ └── index.js
│ │ └── webpack.config.js
│ ├── example3
│ │ ├── README.md
│ │ ├── package.json
│ │ ├── src
│ │ │ └── index.js
│ │ └── webpack.config.js
│ ├── example4
│ │ ├── README.md
│ │ ├── package.json
│ │ ├── src
│ │ │ ├── index.html
│ │ │ ├── index.js
│ │ │ └── styles.css
│ │ └── webpack.config.js
│ ├── example5
│ │ ├── README.md
│ │ ├── package.json
│ │ ├── src
│ │ │ ├── index.html
│ │ │ ├── index.js
│ │ │ └── styles.css
│ │ └── webpack.config.js
│ ├── example6
│ │ ├── README.md
│ │ ├── package.json
│ │ ├── src
│ │ │ ├── index.html
│ │ │ ├── index.js
│ │ │ └── styles.css
│ │ ├── webpack.config.dev.js
│ │ └── webpack.config.prod.js
│ ├── example7
│ │ ├── README.md
│ │ ├── package.json
│ │ ├── src
│ │ │ ├── index.html
│ │ │ ├── index.js
│ │ │ └── styles.css
│ │ ├── webpack.config.dev.js
│ │ └── webpack.config.prod.js
│ └── html-reload
│ │ ├── README.md
│ │ ├── package.json
│ │ ├── src
│ │ ├── index.html
│ │ ├── index.js
│ │ └── styles.css
│ │ ├── webpack.config.dev.js
│ │ └── webpack.config.prod.js
└── part2
│ ├── README.md
│ └── example1
│ ├── .babelrc
│ ├── .eslintrc
│ ├── package.json
│ ├── src
│ ├── index.html
│ ├── index.js
│ └── styles.css
│ ├── webpack.config.dev.js
│ └── webpack.config.prod.js
└── zh-cn
├── README.md
├── part1
├── README.md
├── css-extract
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ ├── changeColor.js
│ │ ├── index.html
│ │ ├── index.js
│ │ └── styles.css
│ ├── webpack.config.dev.js
│ └── webpack.config.prod.js
├── example1
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ ├── APIStuff.js
│ │ ├── UIStuff.js
│ │ ├── extraFile.js
│ │ ├── index.js
│ │ └── styles.css
│ └── webpack.config.js
├── example2
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ └── index.js
│ └── webpack.config.js
├── example3
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ └── index.js
│ └── webpack.config.js
├── example4
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ ├── index.html
│ │ ├── index.js
│ │ └── styles.css
│ └── webpack.config.js
├── example5
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ ├── index.html
│ │ ├── index.js
│ │ └── styles.css
│ └── webpack.config.js
├── example6
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ ├── index.html
│ │ ├── index.js
│ │ └── styles.css
│ ├── webpack.config.dev.js
│ └── webpack.config.prod.js
├── example7
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ ├── index.html
│ │ ├── index.js
│ │ └── styles.css
│ ├── webpack.config.dev.js
│ └── webpack.config.prod.js
└── html-reload
│ ├── README.md
│ ├── package.json
│ ├── src
│ ├── index.html
│ ├── index.js
│ └── styles.css
│ ├── webpack.config.dev.js
│ └── webpack.config.prod.js
└── part2
├── README.md
└── example1
├── .babelrc
├── .eslintrc
├── package.json
├── src
├── index.html
├── index.js
└── styles.css
├── webpack.config.dev.js
└── webpack.config.prod.js
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | dist
3 | bundle.js
4 | npm-debug.log*
5 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 Aria Fallah
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Beginner Webpack Tutorial :school:
2 |
3 | Starting off with webpack was hard for me. I want to create a beginner friendly and comprehensive
4 | intro to webpack.
5 |
6 | - [Part 1](https://github.com/AriaFallah/WebpackTutorial/tree/master/part1) - Webpack Basics and configuration.
7 | - [Part 2](https://github.com/AriaFallah/WebpackTutorial/tree/master/part2) - Babel, linting, and environment variables.
8 |
9 | ### Translations
10 | - [Chinese Traditional](https://github.com/AriaFallah/WebpackTutorial/tree/master/zh-TW)
11 | - [简体中文](./zh-cn)
12 |
--------------------------------------------------------------------------------
/ko-arahansa/README.md:
--------------------------------------------------------------------------------
1 | # 입문자를 위한 Webpack 튜토리얼 :school:
2 |
3 | 웹팩을 시작하는 것은 나에게 매우 힘들었지. 난 그래서 웹팩 입문자를 위한 친절하고 이해하기 쉬운 자료를 만들고 싶었어.
4 |
5 | - [Part 1](https://github.com/AriaFallah/WebpackTutorial/tree/master/ko-arahansa/part1) - 웹팩 기초와 설정을 다룬다.
6 | - [Part 2](https://github.com/AriaFallah/WebpackTutorial/tree/master/ko-arahansa/part2) - Babel, linting과 환경 변수들
7 |
--------------------------------------------------------------------------------
/ko-arahansa/part1/css-extract/README.md:
--------------------------------------------------------------------------------
1 | # Extra - Extract Your CSS
2 |
3 | 예. 당신이 마쳤습니다만, production 에서는 css 파일이 javascript안에 들어가기를 원하지 않습니다. 이러한 목적을 위해서 우리는
4 | [Extract Text Plugin](https://github.com/webpack/extract-text-webpack-plugin).
5 | 을 사용할 것입니다.
6 |
7 | npm install --save-dev extract-text-webpack-plugin
8 |
9 | 그리고 우리의 웹팩 production설정을 다음과 같이 바꿔줘야합니다 :
10 |
11 | ```javascript
12 | var path = require('path')
13 | var webpack = require('webpack')
14 | var HtmlWebpackPlugin = require('html-webpack-plugin')
15 | var ExtractTextPlugin = require("extract-text-webpack-plugin");
16 |
17 | module.exports = {
18 | devtool: 'source-map',
19 | entry: ['./src/index'],
20 | output: {
21 | path: path.join(__dirname, 'dist'),
22 | filename: 'bundle.js'
23 | },
24 | plugins: [
25 | new webpack.optimize.UglifyJsPlugin({
26 | compressor: {
27 | warnings: false,
28 | },
29 | }),
30 | new webpack.optimize.OccurenceOrderPlugin(),
31 | new HtmlWebpackPlugin({
32 | template: './src/index.html'
33 | }),
34 | new ExtractTextPlugin("styles.css")
35 | ],
36 | module: {
37 | loaders: [{
38 | test: /\.css$/,
39 | loader: ExtractTextPlugin.extract("style-loader", "css-loader")
40 | }]
41 | }
42 | }
43 | ```
44 |
45 | 이러한 변화는 [official-repo](https://github.com/webpack/extract-text-webpack-plugin) 에서 유래했습니다. 어떻게 이것이 동작하는 지 알고 싶다면 한번 살펴보세요.
46 |
47 | > 엔트리 청크에서 모든 require("style.css")들은 분리된 css 아웃풋 파일로 이동합니다. 그러니 당신의 스타일들은 더 이상 자바스크립트 안에 들어가지않고 css 번들파일안에 들어가게 됩니다. 만약 당신의 전체적인 스타일 시트 볼륨이 크다면, 이게 더 빠를 겁니다. 왜냐하면 스타일시트번들은 자바스크립트 번들과 병렬로 불러와지기 때문입니다.
48 |
49 | 이제 당신이 `npm run build`를 하면 설정을 사용하여 CSS는 분리된 파일로 들어가게 되고, 흥미롭게도 이미 `inde.html`에 포함(include)될 것입니다.
50 | ```html
51 |
52 |
53 | Webpack Tutorial
54 | <------ MAGICALLY ADDED
55 |
56 |
57 | Very Website
58 |
59 |
60 |
61 |
62 | ```
63 |
--------------------------------------------------------------------------------
/ko-arahansa/part1/css-extract/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "css-extract",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "webpack.config.js",
6 | "scripts": {
7 | "build": "webpack --config webpack.config.prod.js",
8 | "dev": "webpack-dev-server --config webpack.config.dev.js"
9 | },
10 | "keywords": [],
11 | "author": "",
12 | "license": "MIT",
13 | "devDependencies": {
14 | "css-loader": "^0.23.1",
15 | "extract-text-webpack-plugin": "^1.0.1",
16 | "html-webpack-plugin": "^2.8.1",
17 | "style-loader": "^0.13.0",
18 | "webpack": "^1.12.13",
19 | "webpack-dev-server": "^1.14.1"
20 | },
21 | "dependencies": {
22 | "pleasejs": "^0.4.2"
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ko-arahansa/part1/css-extract/src/changeColor.js:
--------------------------------------------------------------------------------
1 | var Please = require('pleasejs')
2 | var div = document.getElementById('color')
3 | var button = document.getElementById('button')
4 |
5 | function changeColor() {
6 | div.style.backgroundColor = Please.make_color()
7 | console.log('pls do work')
8 | }
9 |
10 | button.addEventListener('click', changeColor)
11 |
--------------------------------------------------------------------------------
/ko-arahansa/part1/css-extract/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Webpack Tutorial
4 |
5 |
6 | Very Website
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/ko-arahansa/part1/css-extract/src/index.js:
--------------------------------------------------------------------------------
1 | require('./styles.css')
2 | require('./changeColor.js')
3 |
--------------------------------------------------------------------------------
/ko-arahansa/part1/css-extract/src/styles.css:
--------------------------------------------------------------------------------
1 | h1 {
2 | color: rgb(114, 191, 190);
3 | text-align: center;
4 | }
5 |
6 | #color {
7 | width: 300px;
8 | height: 300px;
9 | margin: 0 auto;
10 | }
11 |
12 | button {
13 | cursor: pointer;
14 | display: block;
15 | width: 100px;
16 | outline: 0;
17 | border: 0;
18 | margin: 20px auto;
19 | }
20 |
--------------------------------------------------------------------------------
/ko-arahansa/part1/css-extract/webpack.config.dev.js:
--------------------------------------------------------------------------------
1 | var path = require('path')
2 | var webpack = require('webpack')
3 | var HtmlWebpackPlugin = require('html-webpack-plugin')
4 |
5 | module.exports = {
6 | devtool: 'cheap-eval-source-map',
7 | entry: [
8 | 'webpack-dev-server/client?http://localhost:8080',
9 | 'webpack/hot/dev-server',
10 | './src/index'
11 | ],
12 | output: {
13 | path: path.join(__dirname, 'dist'),
14 | filename: 'bundle.js'
15 | },
16 | plugins: [
17 | new webpack.HotModuleReplacementPlugin(),
18 | new HtmlWebpackPlugin({
19 | template: './src/index.html'
20 | })
21 | ],
22 | module: {
23 | loaders: [{
24 | test: /\.css$/,
25 | loaders: ['style', 'css']
26 | }]
27 | },
28 | devServer: {
29 | contentBase: './dist',
30 | hot: true
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/ko-arahansa/part1/css-extract/webpack.config.prod.js:
--------------------------------------------------------------------------------
1 | var path = require('path')
2 | var webpack = require('webpack')
3 | var HtmlWebpackPlugin = require('html-webpack-plugin')
4 | var ExtractTextPlugin = require("extract-text-webpack-plugin");
5 |
6 | module.exports = {
7 | devtool: 'source-map',
8 | entry: ['./src/index'],
9 | output: {
10 | path: path.join(__dirname, 'dist'),
11 | filename: 'bundle.js'
12 | },
13 | plugins: [
14 | new webpack.optimize.UglifyJsPlugin({
15 | compressor: {
16 | warnings: false,
17 | },
18 | }),
19 | new webpack.optimize.OccurrenceOrderPlugin(),
20 | new HtmlWebpackPlugin({
21 | template: './src/index.html'
22 | }),
23 | new ExtractTextPlugin("styles.css")
24 | ],
25 | module: {
26 | loaders: [{
27 | test: /\.css$/,
28 | loader: ExtractTextPlugin.extract("style-loader", "css-loader")
29 | }]
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/ko-arahansa/part1/example1/README.md:
--------------------------------------------------------------------------------
1 | # Example 1 - Bundling and Loaders
2 |
3 | 
4 |
5 | 번들링 [예제 1](https://github.com/AriaFallah/WebpackTutorial/tree/master/ko-arahansa/part1/example1)
6 |
7 | 
8 |
9 | 웹팩은 공식적으로 모듈 번들러로 얘기됩니다.만약 당신이 좀 더 모듈과 모듈번들링에 대해서 깊이 있는 정보를 원한다면 여기 두개의 무척 좋은 글을 읽어보세요
10 | [here](https://medium.freecodecamp.com/javascript-modules-a-beginner-s-guide-783f7d7a5fcc#.jw1txw6uh)
11 | and [here](https://medium.com/@preethikasireddy/javascript-modules-part-2-module-bundling-5020383cf306#.lfnspler2).
12 |
13 | 우리는 단순하게 갈 것입니다. 이것이 동작하는 방식은 당신이 하나의 파일을 엔트리 포인트로 설정하는 것입니다.
14 | 이 파일은 당신의 트리의 root가 될 것인데 당신이 다른 파일로부터 파일을 `require` 할 때마다 이 트리에 추가가 되게 됩니다. 당신이 `webpack`을 치면 모든 이러한 파일/모듈들은 하나의 단일 파일로 번들링되게 됩니다.
15 |
16 | 여기 예제가 있습니다. :
17 |
18 | 
19 |
20 | 이 사진은 디렉터리를 보여줍니다 :
21 |
22 | ```
23 | MyDirectory
24 | |- index.js
25 | |- UIStuff.js
26 | |- APIStuff.js
27 | |- styles.css
28 | |- extraFile.js
29 | ```
30 |
31 | 그리고 이것은 당신의 파일의 내용을 보여줍니다.
32 |
33 | ```javascript
34 | // index.js
35 | require('./styles.css')
36 | require('./UIStuff.js')
37 | require('./APIStuff.js')
38 |
39 | // UIStuff.js
40 | var React = require('React')
41 | React.createClass({
42 | // stuff
43 | })
44 |
45 | // APIStuff.js
46 | var fetch = require('fetch') // fetch polyfill
47 | fetch('https://google.com')
48 | ```
49 |
50 | ```css
51 | /* styles.css */
52 | body {
53 | background-color: rgb(200, 56, 97);
54 | }
55 | ```
56 |
57 | 만약 당신이 `webpack` 을 치면 당신은 이 계층구조가 가진 내용들의 번들을 받게 됩니다. 하지만 같은 폴더 내에 있어도 `required`되지 않은 `extraFile.js`은 번들링에 포함되지 않게 됩니다.
58 |
59 | `bundle.js` 는 다음과 같을 것입니다 :
60 |
61 | ```javascript
62 | // contents of styles.css
63 | // contents of UIStuff.js + React
64 | // contents of APIStuff.js + fetch
65 | ```
66 |
67 | 번들되는 것은 당신이 명시적으로 required 한 것들만 번들링됩니다.
68 |
69 | ### Loaders
70 |
71 | (로더) 당신은 아마 눈치 챘겠지만, 위의 예제에서 제가 뭔가 이상한 것을 했었습니다. 저는 자바스크립트 파일에 css파일을 `required` 했습니다.
72 |
73 | 자바스크립트 이외의 것들을 `require` 할 수 있다는 것은 웹팩에서 꽤 좋으면서 흥미롭습니다.
74 | 웹팩에서는 로더라는 것이 존재하는 데, 이러한 로더들을 사용하여서 당신은 `.css` 와 `.png`, `.html` 파일들 같은 것 무엇이든지 `require`할 수 있습니다.
75 |
76 | 예로, 위의 다이어그램에서
77 |
78 | ```javascript
79 | // index.js
80 | require('./styles.css')
81 | ```
82 |
83 | 만약 제가 웹팩설정에 [the style-loader](https://github.com/webpack/style-loader) 와 [the css-loader](https://github.com/webpack/css-loader)를 추가하는 것은 유효할 뿐만 아니라, 제 페이지에 실제로 적용될 것입니다.
84 |
85 | 이것은 당신이 웹팩을 가지고서 할 수 있는 많은 로더들의 하나의 예일뿐입니다.
--------------------------------------------------------------------------------
/ko-arahansa/part1/example1/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example1",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "keywords": [],
10 | "author": "",
11 | "license": "MIT",
12 | "dependencies": {
13 | "fetch": "^1.0.0",
14 | "react": "^0.14.7"
15 | },
16 | "devDependencies": {
17 | "css-loader": "^0.23.1",
18 | "style-loader": "^0.13.0",
19 | "webpack": "^1.12.14"
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/ko-arahansa/part1/example1/src/APIStuff.js:
--------------------------------------------------------------------------------
1 | var fetch = require('fetch') // fetch polyfill
2 | fetch('https://google.com')
3 |
--------------------------------------------------------------------------------
/ko-arahansa/part1/example1/src/UIStuff.js:
--------------------------------------------------------------------------------
1 | var React = require('React')
2 | React.createClass({
3 | // stuff
4 | })
5 |
--------------------------------------------------------------------------------
/ko-arahansa/part1/example1/src/extraFile.js:
--------------------------------------------------------------------------------
1 | console.log('No one likes me')
2 |
--------------------------------------------------------------------------------
/ko-arahansa/part1/example1/src/index.js:
--------------------------------------------------------------------------------
1 | require('./styles.css')
2 | require('./UIStuff.js')
3 | require('./APIStuff.js')
4 |
--------------------------------------------------------------------------------
/ko-arahansa/part1/example1/src/styles.css:
--------------------------------------------------------------------------------
1 | body {
2 | background-color: rgb(200, 56, 97);
3 | }
4 |
--------------------------------------------------------------------------------
/ko-arahansa/part1/example1/webpack.config.js:
--------------------------------------------------------------------------------
1 | var path = require('path')
2 | var webpack = require('webpack')
3 |
4 | module.exports = {
5 | entry: ['./src/index'], // .js after index is optional
6 | output: {
7 | path: path.join(__dirname, 'dist'),
8 | filename: 'bundle.js'
9 | },
10 | plugins: [
11 | new webpack.optimize.UglifyJsPlugin({
12 | compressor: {
13 | warnings: false,
14 | },
15 | }),
16 | new webpack.optimize.OccurrenceOrderPlugin()
17 | ],
18 | module: {
19 | loaders: [{
20 | test: /\.css$/,
21 | loaders: ['style', 'css']
22 | }]
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ko-arahansa/part1/example2/README.md:
--------------------------------------------------------------------------------
1 | # Example 2 - A minimal example
2 |
3 | (최소한의 예제)
4 | [예제 2](https://github.com/AriaFallah/WebpackTutorial/tree/master/ko-arahansa/part1/example2)
5 |
6 | 당신의 디렉터리 구조가 다음과 같다고 합시다 :
7 |
8 | ```
9 | MyDirectory
10 | |- dist
11 | |- src
12 | |- index.js
13 | |- webpack.config.js
14 |
15 | ```
16 |
17 | 그러면 당신의 최소 웹팩 설정은 다음과 같이 만들 수 있을 것입니다.
18 |
19 | ```javascript
20 | // webpack.config.js
21 | var path = require('path')
22 |
23 | module.exports = {
24 | entry: ['./src/index'], // file extension after index is optional for .js files
25 | output: {
26 | path: path.join(__dirname, 'dist'),
27 | filename: 'bundle.js'
28 | }
29 | }
30 | ```
31 |
32 | 새로운 속성들을 하나하나씩 알아보겠습니다 :
33 |
34 | * [entry](https://webpack.github.io/docs/configuration.html#entry) - 당신의 번들의 엔트리포인트입니다. [번들링](#bundling) 섹션에서 좀 더 알아볼 것입니다..
35 |
36 | 웹팩은 여러개의 번들을 생성하기를 원하면, 여러개의 엔트리 포인트들을 허용하기 때문에 엔트리포인트는 배열입니다.
37 |
38 | * [output](https://webpack.github.io/docs/configuration.html#output) - 웹팩에 의해 출력되는 형태를 나타냅니다.
39 | * [path](https://webpack.github.io/docs/configuration.html#output-path) - 번들을 놓을 곳입니다.
40 | * [filename](https://webpack.github.io/docs/configuration.html#output-filename) - 번들을 어떻게 부를 지 나타냅니다.
41 |
42 | `webpack`을 실행하면 이것은 `bundle.js` 라는 파일을 dist폴더 안에 생성할 것입니다.
43 |
--------------------------------------------------------------------------------
/ko-arahansa/part1/example2/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example2",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "webpack.config.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "keywords": [],
10 | "author": "",
11 | "license": "MIT"
12 | }
13 |
--------------------------------------------------------------------------------
/ko-arahansa/part1/example2/src/index.js:
--------------------------------------------------------------------------------
1 | console.log('It works!')
2 |
--------------------------------------------------------------------------------
/ko-arahansa/part1/example2/webpack.config.js:
--------------------------------------------------------------------------------
1 | var path = require('path')
2 |
3 | module.exports = {
4 | entry: ['./src/index'], // .js after index is optional
5 | output: {
6 | path: path.join(__dirname, 'dist'),
7 | filename: 'bundle.js'
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/ko-arahansa/part1/example3/README.md:
--------------------------------------------------------------------------------
1 | # Example 3 - Introducing Plugins
2 |
3 | 당신이 모든 파일들을 한꺼번에 번들링했다가 당신이 그것이 900KB라는 것을 깨달았다고 해봅시다. 이것은 번들을 최소화함으로써 개선될 수 있습니다. 제가 이전에 언급한 [UglifyJsPlugin](https://webpack.github.io/docs/list-of-plugins.html#uglifyjsplugin)를 사용하여서 이러한 문제를 해결할 수 있습니다.
4 |
5 | 당신은 플러그인을 사용하려고 웹팩을 로컬로 설치하고 싶을 겁니다.
6 |
7 | npm install --save-dev webpack
8 |
9 | 당신은 이제 웹팩을 사용하여서 코드를 최소화 하세요
10 |
11 | ```javascript
12 | // webpack.config.js
13 | var path = require('path')
14 | var webpack = require('webpack')
15 |
16 | module.exports = {
17 | entry: ['./src/index'],
18 | output: {
19 | path: path.join(__dirname, 'dist'),
20 | filename: 'bundle.js'
21 | },
22 |
23 | plugins: [
24 | new webpack.optimize.UglifyJsPlugin({
25 | compressor: {
26 | warnings: false,
27 | },
28 | })
29 | ]
30 | }
31 | ```
32 |
33 | 새로운 속성들을 하나하나 알아보도록 하겠습니다 :
34 |
35 | * plugins - 플러그인들을 적을 배열.
36 | * [webpack.optimize.UglifyJsPlugin](https://webpack.github.io/docs/list-of-plugins.html#uglifyjsplugin) - 코드를 최소화하고 경고 메시지를 숨깁니다.
37 |
38 | 여기서 당신이 `webpack`을 칠 때, 당신은 `UglifyJsPlugin`을 가지고서 공백을 제거함으로써 900KB를 200KB 까지 줄일 수 있습니다.
39 |
40 | 당신은 또한 [OccurrenceOrderPlugin](https://webpack.github.io/docs/list-of-plugins.html#occurrenceorderplugin) 을 추가할 수가 있습니다.
41 |
42 | > 모듈을 할당하고 발생 카운트 아이디들을 발생(?chunk)시킵니다. ID들은 종종 적은(짧은) id들을 얻는데 사용됩니다. 이것은 id가 예상가능하며 파일 전체 크기를 경감시켜 추천됩니다.
43 |
44 | 솔직히 어떤 메커니즘이 하부에 있는 지 모르겠지만 현재(1버젼?)에서는 기본으로 들어가지 않기 때문에 [webpack2 beta it's included by default](https://gist.github.com/sokra/27b24881210b56bbaff7), 이것또한 추가해줬습니다 .
45 |
46 |
47 | ```JavaScript
48 | // webpack.config.js
49 | var path = require('path')
50 | var webpack = require('webpack')
51 |
52 | module.exports = {
53 | entry: ['./src/index'],
54 | output: {
55 | path: path.join(__dirname, 'dist'),
56 | filename: 'bundle.js'
57 | },
58 | plugins: [
59 | new webpack.optimize.UglifyJsPlugin({
60 | compressor: {
61 | warnings: false,
62 | },
63 | }),
64 | new webpack.optimize.OccurrenceOrderPlugin()
65 | ]
66 | }
67 | ```
68 |
69 | 우리는 설정파일을 써서 우리의 번들 자바스크립트 파일을 최소화하였습니다. 이 번들은 다른 프로젝트의 디렉터리로 복사될 수 있습니다. 그리고 그곳의 script태그로 던져질 수 있습니다. 만약 당신이 웹팩의 기초만을 *자바스크립트만* 사용하기를 원한다면 [결론](#conclusion)을 생략할 수 있습니다.
--------------------------------------------------------------------------------
/ko-arahansa/part1/example3/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example3",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "webpack.config.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "keywords": [],
10 | "author": "",
11 | "license": "MIT",
12 | "devDependencies": {
13 | "webpack": "^1.12.13"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/ko-arahansa/part1/example3/src/index.js:
--------------------------------------------------------------------------------
1 | console.log('It works!')
2 |
--------------------------------------------------------------------------------
/ko-arahansa/part1/example3/webpack.config.js:
--------------------------------------------------------------------------------
1 | var path = require('path')
2 | var webpack = require('webpack')
3 |
4 | module.exports = {
5 | entry: ['./src/index'], // .js after index is optional
6 | output: {
7 | path: path.join(__dirname, 'dist'),
8 | filename: 'bundle.js'
9 | },
10 | plugins: [
11 | new webpack.optimize.UglifyJsPlugin({
12 | compressor: {
13 | warnings: false,
14 | },
15 | }),
16 | new webpack.optimize.OccurrenceOrderPlugin()
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/ko-arahansa/part1/example4/README.md:
--------------------------------------------------------------------------------
1 | 이 튜토리얼의 앞에서 [로더들](#loaders)을 얘기했듯이, 이것들은 우리에게 js파일이 아닌것을 우리의 코드에 require하게 해줍니다. 이러한 경우 우리는 style loader 와 css loader를 필요로 합니다. 먼저 이 로더들을 설치하도록 하겠습니다:
2 |
3 | npm install --save-dev style-loader css-loader
4 |
5 | 이제 이것들은 설치되었고 설정을 좀 더 바꿔서 css loader 를 추가해줘보도록 하겠습니다. :
6 |
7 |
8 | ```javascript
9 | // webpack.config.js
10 | var path = require('path')
11 | var webpack = require('webpack')
12 |
13 | module.exports = {
14 | entry: ['./src/index'],
15 | output: {
16 | path: path.join(__dirname, 'dist'),
17 | filename: 'bundle.js'
18 | },
19 | plugins: [
20 | new webpack.optimize.UglifyJsPlugin({
21 | compressor: {
22 | warnings: false,
23 | },
24 | }),
25 | new webpack.optimize.OccurrenceOrderPlugin()
26 | ],
27 | module: {
28 | loaders: [{
29 | test: /\.css$/,
30 | loaders: ['style', 'css']
31 | }]
32 | }
33 | }
34 | ```
35 |
36 | 새로운 속성들을 하나하나 알아보도록 하겠습니다 :
37 |
38 | * [모듈](http://webpack.github.io/docs/configuration.html#module) - 당신의 파일들에 영향을 주는 옵션들 입니다.
39 | * [loaders](http://webpack.github.io/docs/configuration.html#module-loaders) - 어플리케이션을 위해 적어줄 로더들의 배열입니다.
40 | * test - 로더가 적용될 파일을 매칭하기 위한 정규식입니다.
41 | * loaders - test에서 매칭된 파일에 어떤 로더를 사용할지 결정합니다.
42 |
43 | 여기서 우리가 `webpack`을 실행할 때, 만약 당신이 `.css`로 끝나는 파일들을 `require` 했다면 우리는 이것들에 `style`과 `css` 로더를 적용하고 번들에 해당 css를 추가합니다.
44 |
45 | 만약 우리가 로더들을 가지고 있지 않았다면, 우리는 다음과 같은 에러를 얻을 것입니다 :
46 |
47 | ```
48 | ERROR in ./test.css
49 | Module parse failed: /Users/Developer/workspace/tutorials/webpack/part1/example1/test.css
50 | Line 1: Unexpected token {
51 | You may need an appropriate loader to handle this file type.
52 | ```
53 |
54 | **Optional(옵션)**
55 |
56 | 만약 당신이 CSS대신에 SCSS 를 사용하기를 원핟다면 다음과 같이 실행하세요 :
57 |
58 | npm install --save-dev sass-loader node-sass webpack
59 |
60 | 그리고 로더 부분을 다음과 같이 적으세요..
61 |
62 | ```javascript
63 | {
64 | test: /\.scss$/,
65 | loaders: ["style", "css", "sass"]
66 | }
67 | ```
68 |
69 | LESS도 비슷합니다.
70 |
71 | 로더를 인식하는 점에서 중요한 점은 이러한 로더들이 적혀지는 *순서*입니다. 위의 예제에서 `sass`로더가 제일 처음 당신의 `.scss` 파일들에 적용이 되고 그리고 `css`로더가 적용이 되며 마지막으로 `style`로더가 적용이 되게 됩니다. 당신이 볼 수 있듯이, 패턴이 적용되는 순서는 오른쪽에서 왼쪽입니다.
72 |
--------------------------------------------------------------------------------
/ko-arahansa/part1/example4/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example4",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "webpack.config.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "keywords": [],
10 | "author": "",
11 | "license": "MIT",
12 | "devDependencies": {
13 | "webpack": "^1.12.13"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/ko-arahansa/part1/example4/src/index.html:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriaFallah/WebpackTutorial/ada78b7f505da40e3a6985f272047cebca9cf40d/ko-arahansa/part1/example4/src/index.html
--------------------------------------------------------------------------------
/ko-arahansa/part1/example4/src/index.js:
--------------------------------------------------------------------------------
1 | console.log('It works!')
2 |
--------------------------------------------------------------------------------
/ko-arahansa/part1/example4/src/styles.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriaFallah/WebpackTutorial/ada78b7f505da40e3a6985f272047cebca9cf40d/ko-arahansa/part1/example4/src/styles.css
--------------------------------------------------------------------------------
/ko-arahansa/part1/example4/webpack.config.js:
--------------------------------------------------------------------------------
1 | var path = require('path')
2 | var webpack = require('webpack')
3 |
4 | module.exports = {
5 | entry: ['./src/index'], // .js after index is optional
6 | output: {
7 | path: path.join(__dirname, 'dist'),
8 | filename: 'bundle.js'
9 | },
10 | plugins: [
11 | new webpack.optimize.UglifyJsPlugin({
12 | compressor: {
13 | warnings: false,
14 | },
15 | }),
16 | new webpack.optimize.OccurrenceOrderPlugin()
17 | ],
18 | module: {
19 | loaders: [{
20 | test: /\.css$/,
21 | loaders: ['style', 'css']
22 | }]
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ko-arahansa/part1/example5/README.md:
--------------------------------------------------------------------------------
1 | # Example 5 - Adding More Plugins
2 |
3 | 이제 우리는 우리의 우리가 스타일할 실제 웹페이지에 스타일을 적용할 수 있을 기반을 가졌습니다.
4 | 우리는 이것을 [html-webpack-plugin](https://github.com/ampedandwired/html-webpack-plugin)을 통해서 할 것인데 이것은 HTML페이지를 생성하거나 이미 존재하는 페이지를 사용합니다. 우리는 이미 존재하는 `index.html`을 사용하고자 합니다.
5 |
6 | 먼저 플러그인을 설치해보도록 하겠습니다 :
7 |
8 | npm install --save-dev html-webpack-plugin@2
9 |
10 |
11 | 그리고 우리는 우리의 설정파일에 추가해보도록 하겠습니다.
12 |
13 | ```javascript
14 | // webpack.config.js
15 | var path = require('path')
16 | var webpack = require('webpack')
17 | var HtmlWebpackPlugin = require('html-webpack-plugin')
18 |
19 | module.exports = {
20 | entry: ['./src/index'],
21 | output: {
22 | path: path.join(__dirname, 'dist'),
23 | filename: 'bundle.js'
24 | },
25 | plugins: [
26 | new webpack.optimize.UglifyJsPlugin({
27 | compressor: {
28 | warnings: false,
29 | },
30 | }),
31 | new webpack.optimize.OccurrenceOrderPlugin(),
32 | new HtmlWebpackPlugin({
33 | template: './src/index.html'
34 | })
35 | ],
36 | module: {
37 | loaders: [{
38 | test: /\.css$/,
39 | loaders: ['style', 'css']
40 | }]
41 | }
42 | }
43 | ```
44 |
45 | 여기서 우리는 `webpack`을 실행하면, 우리가 `HtmlWebpackPlugin`을 `./src/index.html`에 적용해뒀기 때문에, 이것은 `dist`폴더에 `./src/index.html`를 기반으로 하여서 `index.html` 을 생성할 것입니다.
46 |
47 | (There's no point in using `index.html` as a template if it's empty.)
48 | 이제 실제로 실제로 index.html을 만들어봅시다.
49 |
50 | ```html
51 |
52 |
53 | Webpack Tutorial
54 |
55 |
56 | Very Website
57 |
58 |
59 |
60 |
61 | ```
62 |
63 | 여기서 우리는 `bundle.js` 를 위한 `