Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d217156

Browse filesBrowse files
README.md
1 parent fc622f4 commit d217156
Copy full SHA for d217156

File tree

Expand file treeCollapse file tree

1 file changed

+13
-28
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+13
-28
lines changed
Open diff view settings
Collapse file

‎09-Tools/01-webpack/README.md‎

Copy file name to clipboardExpand all lines: 09-Tools/01-webpack/README.md
+13-28Lines changed: 13 additions & 28 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -496,34 +496,20 @@ localhost:8080
496496
Babel其实可以完全在 `webpack.config.js` 中进行配置,但是考虑到babel具有非常多的配置选项,在单一的`webpack.config.js`文件中进行配置往往使得这个文件显得太复杂,因此一些开发者支持把babel的配置选项放在一个单独的名为 ".babelrc" 的配置文件中。我们现在的babel的配置并不算复杂,不过之后我们会再加一些东西,因此现在我们就提取出相关部分,分两个配置文件进行配置(webpack会自动调用`.babelrc`里的babel配置选项),如下:
497497

498498
```
499-
// webpack.config.js
500499
module.exports = {
501-
devtool: 'eval-source-map',
502-
503-
entry: __dirname + "/app/main.js",
504-
output: {
505-
path: __dirname + "/public",
506-
filename: "bundle.js"
507-
},
508-
509-
module: {
510-
loaders: [
511-
{
512-
test: /\.json$/,
513-
loader: "json"
514-
},
515-
{
516-
test: /\.js$/,
517-
exclude: /node_modules/,
518-
loader: 'babel'
519-
}
520-
]
521-
},
522-
523-
devServer: {...} // Omitted for brevity
524-
}
525-
526-
500+
...
501+
module: {
502+
rules: [
503+
{
504+
test: /(\.jsx|\.js)$/,
505+
use: {
506+
loader: "babel-loader"
507+
},
508+
exclude: /node_modules/
509+
}
510+
]
511+
}
512+
};
527513
```
528514

529515
```
@@ -579,7 +565,6 @@ module.exports = {
579565
]
580566
}
581567
};
582-
583568
```
584569

585570
> 请注意这里对同一个文件引入多个loader的方法。

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.