Skip to content

Commit 38cc26d

Browse files
fix conflict and table of content link
1 parent 566ba49 commit 38cc26d

File tree

5 files changed

+105
-93
lines changed

5 files changed

+105
-93
lines changed

part1/README.md

Lines changed: 42 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ make a pull request.
3030
* [Bundling](#bundling)
3131
* [Loaders](#loaders)
3232
* [Plugins](#plugins)
33-
<<<<<<< HEAD
3433
* [Your Config File](#your-config-file)
3534
* [A Minimal Example](#a-minimal-example)
3635
* [Introducing Plugins](#introducing-plugins)
@@ -41,18 +40,6 @@ make a pull request.
4140
* [Start Coding](#start-coding)
4241
* [Conclusion](#conclusion)
4342
* [Closing Thoughts](#closing-thoughts)
44-
=======
45-
* [你的設定檔案](#your-config-file)
46-
* [一個簡單的範例](#a-minimal-example)
47-
* [介紹 Plugins](#introducing-plugins)
48-
* [一個更完整的範例](#a-more-complete-example)
49-
* [介紹 Loaders](#introducing-loaders)
50-
* [加入更多 Plugins](#adding-more-plugins)
51-
* [開發伺服器](#the-development-server)
52-
* [開始撰寫程式](#start-coding)
53-
* [結論](#conclusion)
54-
* [結束後的思考](#closing-thoughts)
55-
>>>>>>> bd62391... translate ex5 ex6
5643

5744
## Why Webpack?
5845

@@ -367,17 +354,10 @@ MyDirectory
367354

368355
#### Contents
369356

370-
<<<<<<< HEAD
371357
1. [Introducing Loaders](#introducing-loaders) - We will add loaders, which allow us to add CSS to our bundle.
372358
2. [Adding More Plugins](#adding-more-plugins) - We will add a plugin that'll help us create/use an HTML file.
373359
3. [The Development Server](#the-development-server) - We'll split our webpack config into separate `development` and `production` files. Then use the webpack-dev-server to view our website and enable HMR.
374360
4. [Start Coding](#start-coding) - We will actually write some JavaScript.
375-
=======
376-
1. [介紹 Loader](#introducing-loaders) - 我們將會加入 loader,這可以讓我 bundle 加入的 CSS。
377-
2. [加入更多 Plugin](#adding-more-plugins) - 我們加入一個 plugin 來幫助我們建立和使用一個 HTML 檔案。
378-
3. [開發伺服器](#the-development-server) - 我們會將 webpack 設定檔案分為 `development 和 `production` 兩種版本,然後使用 webpack-dev-server 來查看我們的網站並啟用 HMR。
379-
4. [開始撰寫程式](#start-coding) - 我們來實際寫一些 JavaScript。
380-
>>>>>>> bd62391... translate ex5 ex6
381361

382362
#### Introducing Loaders
383363

@@ -551,18 +531,23 @@ button {
551531
}
552532
```
553533

554-
#### 開發伺服器
534+
#### The Development Server
555535

556-
[範例六](https://github.com/AriaFallah/WebpackTutorial/tree/master/part1/example6)
536+
[Example 6](https://github.com/AriaFallah/WebpackTutorial/tree/master/part1/example6)
557537

558-
現在我們想要實際在瀏覽器看到我們的網站,需要一個 web 伺服器來服務我們的程式碼。webpack 自帶了方便的 `webpack-dev-server`,你需要在本機和全域安裝。
538+
Now we want to actually see our website in the browser, which requires a web server to serve our
539+
code. Conveniently, webpack comes with the `webpack-dev-server`, which you need to install both
540+
locally and globally
559541

560542
npm install -g webpack-dev-server
561543
npm install --save-dev webpack-dev-server
562544

563-
dev server 可以在瀏覽器看到你的網站是怎麼樣子以及可以更快速的開發,是一個相當有用的資源。預設情況下你可以拜訪 `http://localhost:8080`。不幸的是,像是 hot reloading 的功能並不是內建的,還需要一些其他的設定。
545+
The dev server is an extremely useful resource for seeing what your website looks like in the browser, and more rapid development. By default you can visit it at `http://localhost:8080`. Unfortunately, features such as hot reloading don't work out of the box, and require some more configuration.
564546

565-
這是 webpack 設定檔一個很棒的分離點,意思是說你可以將他分成用於「development」以及「production」。因為我們必須在這個教學中保持簡單的方式,所不會有很大的改變,但是會介紹 webpack 很棒的可設置性。我們稱他們為 `webpack.config.dev.js``webpack.config.prod.js`
547+
This is a good point to split up our webpack config into one meant for development and one meant for
548+
production. Since we're keeping it simple in this tutorial, it won't be a huge difference, but it's
549+
an introduction to the extreme configurability of webpack. We'll call them `webpack.config.dev.js`
550+
and `webpack.config.prod.js`.
566551

567552
```javascript
568553
// webpack.config.dev.js
@@ -601,20 +586,22 @@ module.exports = {
601586
```
602587

603588

604-
**修改**
589+
**Changes**
605590

606-
1. dev 設定檔省略了優化,當你不斷的 rebuild 時,他們不是必要的。所以不需要 `webpack.optimize` plugins。
591+
1. The dev config omits the optimizations as they are unnecessary overhead when you are constantly
592+
rebuilding. So no `webpack.optimize` plugins.
607593

608-
2. dev 設定檔需要對 dev server 做必要的設定,你可以到[這裡](https://webpack.github.io/docs/webpack-dev-server.html)了解更多。
594+
2. The dev config has the necessary configuration for the dev server, which you can read more about
595+
[here](https://webpack.github.io/docs/webpack-dev-server.html).
609596

610-
總結:
597+
Summarized:
611598

612-
* entry: 兩個新的進入點將伺服器連結到瀏覽器,方便 HMR
599+
* entry: The two new entry points connect the server to the browser to allow for HMR.
613600
* devServer
614-
* contentBase: 服務的檔案來自哪裡。
615-
* hot: 啟用 HMR
601+
* contentBase: Where to serve files from
602+
* hot: enable HMR
616603

617-
prod 設定檔不需要改變太多:
604+
The prod config doesn't change much
618605

619606
```javascript
620607
// webpack.config.prod.js
@@ -649,22 +636,28 @@ module.exports = {
649636
}
650637
```
651638

652-
我也加入一個全新的屬性在 dev prod 設定檔:
639+
I've also added a brand new property to both the dev config and the prod config:
653640

654-
* [devtool](https://webpack.github.io/docs/configuration.html#devtool) - 這是協助 debug 的。基本上,當你得到一個錯誤,它會幫助你找到哪裡發生了錯誤,像是 chrome developer console。`source-map``cheap-eval-source-map` 之間的差異從文件說明有點難解釋。我可以肯定的是,`source-map` 是用於 production,`cheap-eval-source-map` 是用於 `development`
641+
* [devtool](https://webpack.github.io/docs/configuration.html#devtool) - This is a debugging aid.
642+
Basically, when you get a error, it'll help you see where you made the mistake something like the
643+
chrome developer console. As for the difference between `source-map` and `cheap-eval-source-map`
644+
it's a little hard to glean from the docs. What I can say definitively is that `source-map` is meant
645+
for production and has a lot of overhead, and that `cheap-eval-source-map` has less overhead and is
646+
meant for developing only.
655647

656-
如果要執行 dev server,我們可以執行:
648+
To run the dev server we have to run
657649

658650
webpack-dev-server --config webpack.config.dev.js
659651

660-
如果我們要 build production 的程式碼,我們可以執行:
652+
and to build the production code we have to run
661653

662654
webpack --config webpack.config.prod.js
663655

664656

665-
如果想要讓這些指令使用的更容易,我們可以到 `package.json` 來設定簡單的 script。
657+
To make our lives a little easier we are now going to use `package.json` as a simple task runner so
658+
that we don't need to keep typing out either command.
666659

667-
我們加入 `scripts` 屬性到設定檔:
660+
We add the `scripts` property to the config
668661

669662
```javascript
670663
// package.json
@@ -678,20 +671,25 @@ module.exports = {
678671
}
679672
```
680673

681-
我們可以執行這些指令:
674+
We can run these commands with
682675

683676
```
684677
npm run build
685678
npm run dev
686679
```
687680

688-
你現在可以透過 `npm run dev`,並導到 `http://localhost:8080` 看到你的網站。
681+
You can now view your beautiful website by running `npm run dev`, and navigating to
682+
`http://localhost:8080`.
689683

690-
**備註:** 當我正在測試這個部份時,我明白到當我修改 `index.html` 檔案時,伺服器不能 hot reload。 解決這個問題的方法在 [html-reload](https://github.com/AriaFallah/WebpackTutorial/tree/master/part1/html-reload)。這裡涵蓋了一些 webpack 設定檔選項的有用資訊,我推薦你可以看一下,但是我把它分開了,因為我覺得會因為這個不太重要的原因,這會延長這個教學。
684+
**Side Note:** while I was testing this portion I realized that the server would not hot reload
685+
when I modified the `index.html` file. The solution to this problem is over at
686+
[html-reload](https://github.com/AriaFallah/WebpackTutorial/tree/master/part1/html-reload). It's useful
687+
information that covers some more configuration options of webpack, which I recommend looking at,
688+
but I left it separate because I feel like it lengthens the tutorial for too trivial of a reason.
691689

692-
#### 開始撰寫程式
690+
#### Start Coding
693691

694-
[範例七](https://github.com/AriaFallah/WebpackTutorial/tree/master/part1/example7)
692+
[Example 7](https://github.com/AriaFallah/WebpackTutorial/tree/master/part1/example7)
695693

696694
The reason most people seem to be flustered by webpack is the fact that they need to go through all
697695
of this to get to the point where they finally write JavaScript; however, now we have arrived at the

part1/example5/README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,4 @@ new HtmlWebpackPlugin({
118118
})
119119
```
120120

121-
<<<<<<< HEAD
122121
Anyone with other experience feel free to correct me if I'm wrong.
123-
=======
124-
如果我錯了,請任何有這方面經驗的人隨時糾正我。
125-
>>>>>>> bd62391... translate ex5 ex6

part1/example6/README.md

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1-
# 範例六 - 開發伺服器
1+
# Example 6 - The Development Server
22

3-
現在我們想要實際在瀏覽器看到我們的網站,需要一個 web 伺服器來服務我們的程式碼。webpack 自帶了方便的 `webpack-dev-server`,你需要在本機和全域安裝。
3+
Now we want to actually see our website in the browser, which requires a web server to serve our
4+
code. Conveniently, webpack comes with the `webpack-dev-server`, which you need to install both
5+
locally and globally
46

57
npm install -g webpack-dev-server
68
npm install --save-dev webpack-dev-server
79

8-
dev server 可以在瀏覽器看到你的網站是怎麼樣子以及可以更快速的開發,是一個相當有用的資源。預設情況下你可以拜訪 `http://localhost:8080`。不幸的是,像是 hot reloading 的功能並不是內建的,還需要一些其他的設定。
10+
The dev server is an extremely useful resource for seeing what your website looks like in the browser, and more rapid development. By default you can visit it at `http://localhost:8080`. Unfortunately, features such as hot reloading don't work out of the box, and require some more configuration.
911

10-
這是 webpack 設定檔一個很棒的分離點,意思是說你可以將他分成用於「development」以及「production」。因為我們必須在這個教學中保持簡單的方式,所不會有很大的改變,但是會介紹 webpack 很棒的可設置性。我們稱他們為 `webpack.config.dev.js``webpack.config.prod.js`
12+
This is a good point to split up our webpack config into one meant for development and one meant for
13+
production. Since we're keeping it simple in this tutorial, it won't be a huge difference, but it's
14+
an introduction to the extreme configurability of webpack. We'll call them `webpack.config.dev.js`
15+
and `webpack.config.prod.js`.
1116

1217
```javascript
1318
// webpack.config.dev.js
@@ -46,21 +51,23 @@ module.exports = {
4651
```
4752

4853

49-
**修改**
54+
**Changes**
5055

51-
1. dev 設定檔省略了優化,當你不斷的 rebuild 時,他們不是必要的。所以不需要 `webpack.optimize` plugins。
56+
1. The dev config omits the optimizations as they are unnecessary overhead when you are constantly
57+
rebuilding. So no `webpack.optimize` plugins.
5258

53-
2. dev 設定檔需要對 dev server 做必要的設定,你可以到[這裡](https://webpack.github.io/docs/webpack-dev-server.html)了解更多。
59+
2. The dev config has the necessary configuration for the dev server, which you can read more about
60+
[here](https://webpack.github.io/docs/webpack-dev-server.html).
5461

55-
總結:
62+
Summarized:
5663

57-
* entry: 兩個新的進入點將伺服器連結到瀏覽器,方便 HMR
64+
* entry: The two new entry points connect the server to the browser to allow for HMR.
5865
* devServer
59-
* contentBase: 服務的檔案來自哪裡。
60-
* hot: 啟用 HMR
66+
* contentBase: Where to serve files from
67+
* hot: enable HMR
6168
---
6269

63-
prod 設定檔不需要改變太多:
70+
The prod config doesn't change much
6471

6572
```javascript
6673
// webpack.config.prod.js
@@ -95,22 +102,28 @@ module.exports = {
95102
}
96103
```
97104

98-
我也加入一個全新的屬性在 dev prod 設定檔:
105+
I've also added a brand new property to both the dev config and the prod config:
99106

100-
* [devtool](https://webpack.github.io/docs/configuration.html#devtool) - 這是協助 debug 的。基本上,當你得到一個錯誤,它會幫助你找到哪裡發生了錯誤,像是 chrome developer console。`source-map``cheap-eval-source-map` 之間的差異從文件說明有點難解釋。我可以肯定的是,`source-map` 是用於 production,`cheap-eval-source-map` 是用於 `development`
107+
* [devtool](https://webpack.github.io/docs/configuration.html#devtool) - This is a debugging aid.
108+
Basically, when you get a error, it'll help you see where you made the mistake something like the
109+
chrome developer console. As for the difference between `source-map` and `cheap-eval-source-map`
110+
it's a little hard to glean from the docs. What I can say definitively is that `source-map` is meant
111+
for production and has a lot of overhead, and that `cheap-eval-source-map` has less overhead and is
112+
meant for developing only.
101113

102-
如果要執行 dev server,我們可以執行:
114+
To run the dev server we have to run
103115

104116
webpack-dev-server --config webpack.config.dev.js
105117

106-
如果我們要 build production 的程式碼,我們可以執
118+
and to build the production code we have to run
107119

108120
webpack --config webpack.config.prod.js
109121

110122

111-
如果想要讓這些指令使用的更容易,我們可以到 `package.json` 來設定簡單的 script。
123+
To make our lives a little easier we are now going to use `package.json` as a simple task runner so
124+
that we don't need to keep typing out either command.
112125

113-
我們加入 `scripts` 屬性到設定檔:
126+
We add them `scripts` property of the config
114127

115128
```javascript
116129
// package.json
@@ -124,13 +137,18 @@ module.exports = {
124137
}
125138
```
126139

127-
我們可以執行這些指令:
140+
We can run these commands with
128141

129142
```
130143
npm run build
131144
npm run dev
132145
```
133146

134-
你現在可以透過 `npm run dev`,並導到 `http://localhost:8080` 看到你的網站。
147+
You can now view your beautiful website by running `npm run dev`, and navigating to
148+
`http://localhost:8080`.
135149

136-
**備註:** 當我正在測試這個部份時,我明白到當我修改 `index.html` 檔案時,伺服器不能 hot reload。 解決這個問題的方法在 [html-reload](https://github.com/AriaFallah/WebpackTutorial/tree/master/part1/html-reload)。這裡涵蓋了一些 webpack 設定檔選項的有用資訊,我推薦你可以看一下,但是我把它分開了,因為我覺得會因為這個不太重要的原因,這會延長這個教學。
150+
**Side Note:** while I was testing this portion I realized that the server would not hot reload
151+
when I modified the `index.html` file. The solution to this problem is over at
152+
[extra](https://github.com/AriaFallah/WebpackTutorial/tree/master/part1/html-reload). It's useful
153+
information that covers some more configuration options of webpack, which I recommend looking at,
154+
but I left it separate because I feel like it lengthens the tutorial for too trivial of a reason.

zh-TW/part1/README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,22 @@
2020

2121
## 目錄
2222

23-
* [為什麼要 Webpack?](#why-webpack)
24-
* [基礎](#the-basics)
25-
* [安裝](#installation)
23+
* [為什麼要 Webpack?](#為什麼要-webpack)
24+
* [基礎](#基礎)
25+
* [安裝](#安裝)
2626
* [Bundling](#bundling)
2727
* [Loaders](#loaders)
2828
* [Plugins](#plugins)
29-
* [你的設定檔案](#your-config-file)
30-
* [一個簡單的範例](#a-minimal-example)
31-
* [介紹 Plugins](#introducing-plugins)
32-
* [一個更完整的範例](#a-more-complete-example)
33-
* [介紹 Loaders](#introducing-loaders)
34-
* [加入更多 Plugins](#adding-more-plugins)
35-
* [開發伺服器](#the-development-server)
36-
* [開始撰寫程式](#start-coding)
37-
* [結論](#conclusion)
38-
* [反思](#closing-thoughts)
29+
* [你的設定檔案](#你的設定檔案)
30+
* [一個簡單的範例](#一個簡單的範例)
31+
* [介紹 Plugins](#介紹-plugins)
32+
* [一個更完整的範例](#一個更完整的範例)
33+
* [介紹 Loaders](#介紹-loaders)
34+
* [加入更多的 Plugins](#加入更多的-plugins)
35+
* [開發伺服器](#開發伺服器)
36+
* [開始撰寫程式](#開始撰寫程式)
37+
* [結論](#結論)
38+
* [反思](#反思)
3939

4040
## 為什麼要 Webpack?
4141

@@ -399,7 +399,7 @@ You may need an appropriate loader to handle this file type.
399399

400400
要知道這些需要被指定的 loader 是有*順序*的,這是一個很重要部分。在上面的範例,`sass` loader 是第一個應用在你的 `.scss` 檔案,然後是 `css` loader,最後是 `style` loader。你可以看到,這些 loader 的應用模式是由右到左。
401401

402-
#### 加入更多的 Plugin
402+
#### 加入更多的 Plugins
403403

404404
[範例五](https://github.com/neighborhood999/WebpackTutorial/tree/master/zh-TW/part1/example5)
405405

zh-TW/part2/README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@
1818
## 目錄
1919

2020
* [Babel](#babel)
21-
* [Babel 是做什麼用的?](#what-does-babel-do)
22-
* [設定 Babel](#configuring-babel)
21+
* [Babel 是做什麼用的?](#babel-是做什麼用的)
22+
* [設定 Babel](#設定-babel)
2323
* [Webpack](#webpack)
24-
* [一個新的 Loader](#a-new-loader)
25-
* [我們完成了?](#we-are-done)
26-
* [Require ES6 的 Module](#requiring-with-es6-modules)
27-
* [額外收穫](#extra-credit)
28-
* [Production 環境變數以及 Webpack 和 Babel](#production-environment-variables-with-webpack-and-babel)
29-
* [加入 Lint](#adding-linting)
30-
* [結論](#conclusion)
24+
* [一個新的 Loader](#一個新的-loader)
25+
* [我們完成了?](#我們完成了)
26+
* [Require ES6 的 Module](#require-es6-的-module)
27+
* [額外收穫](#額外收穫)
28+
* [Production 環境變數以及 Webpack 和 Babel](#production-環境變數以及-webpack--babel)
29+
* [加入 Lint](#加入-lint)
30+
* [結論](#結論)
3131

3232

3333
## Babel
@@ -197,7 +197,7 @@ module: {
197197

198198
另一個方式,你可以將 `include: path.join(__dirname, 'src')` 改變成 `exclude: /node_modules/`,除了 `node_modules` 目錄外其他都包括。更多資訊可以在[這裡](https://webpack.github.io/docs/configuration.html#module-loaders)找到。
199199

200-
## 我們完成了嗎
200+
## 我們完成了
201201

202202
老實說,我覺得這個教學過程有點太長了,看起來我似乎忘了加入 babel 實際上不是這麼的重要。我們現在可以使用 ES6 語法更新先前在 `index.js` 的程式碼:
203203

0 commit comments

Comments
 (0)