Skip to content

Commit 03aa60d

Browse files
authored
Merge pull request #279 from webpack/loader-extension
Add `-loader` to every loader name
2 parents 49256f7 + ce140ca commit 03aa60d

File tree

8 files changed

+104
-81
lines changed

8 files changed

+104
-81
lines changed

antwar.config.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ module.exports = {
3131
'/': root(
3232
function() {
3333
return require.context(
34-
'json!yaml-frontmatter!./content',
34+
'json-loader!yaml-frontmatter-loader!./content',
3535
false,
3636
/^\.\/.*\.md$/
3737
);
@@ -41,7 +41,7 @@ module.exports = {
4141
'Concepts',
4242
function() {
4343
return require.context(
44-
'json!yaml-frontmatter!./content/concepts',
44+
'json-loader!yaml-frontmatter-loader!./content/concepts',
4545
false,
4646
/^\.\/.*\.md$/
4747
);
@@ -51,7 +51,7 @@ module.exports = {
5151
'Configuration',
5252
function() {
5353
return require.context(
54-
'json!yaml-frontmatter!./content/configuration',
54+
'json-loader!yaml-frontmatter-loader!./content/configuration',
5555
false,
5656
/^\.\/.*\.md$/
5757
);
@@ -61,7 +61,7 @@ module.exports = {
6161
'How to',
6262
function() {
6363
return require.context(
64-
'json!yaml-frontmatter!./content/how-to',
64+
'json-loader!yaml-frontmatter-loader!./content/how-to',
6565
true,
6666
/^\.\/.*\.md$/
6767
);
@@ -71,7 +71,7 @@ module.exports = {
7171
'API',
7272
function() {
7373
return require.context(
74-
'json!yaml-frontmatter!./content/api',
74+
'json-loader!yaml-frontmatter-loader!./content/api',
7575
false,
7676
/^\.\/.*\.md$/
7777
);
@@ -81,7 +81,7 @@ module.exports = {
8181
'Loaders',
8282
function() {
8383
return require.context(
84-
'json!yaml-frontmatter!./generated/loaders',
84+
'json-loader!yaml-frontmatter-loader!./generated/loaders',
8585
false,
8686
/^\.\/.*\.md$/
8787
);
@@ -91,7 +91,7 @@ module.exports = {
9191
'Plugins',
9292
function() {
9393
return require.context(
94-
'json!yaml-frontmatter!./generated/plugins',
94+
'json-loader!yaml-frontmatter-loader!./generated/plugins',
9595
false,
9696
/^\.\/.*\.md$/
9797
);

content/concepts/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: Introduction
33
contributors:
44
- TheLarkInn
5+
- jhnns
56
---
67

78
*webpack* is a _module bundler_ for modern JavaScript applications. It is [incredibly configurable](/configuration), however, there are **4 Core Concepts** we feel you should understand before you get started!

content/concepts/plugins.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ title: Plugins
33
sort: 3
44
contributors:
55
- TheLarkInn
6+
- jhnns
67
---
78

89
**Plugins** are the [backbone](https://github.com/webpack/tapable) of webpack. webpack itself is built on the **same plugin system** that you use in your webpack configuration!!

content/how-to/hot-module-reload.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: How to Configure Hot Module Replacement?
33
contributors:
44
- jmreidy
5+
- jhnns
56
---
67

78
Hot Module Replacement (HMR) exchanges, adds, or removes modules while an
@@ -116,14 +117,14 @@ module.exports = env => {
116117
loaders: [
117118
{ test: /\.js$/,
118119
loaders: [
119-
'babel',
120+
'babel-loader',
120121
],
121122
exclude: /node_modules/
122123
},
123124
{
124125
test: /\.css$/,
125126
loaders: [
126-
'style',
127+
'style-loader',
127128
'css-loader?modules',
128129
'postcss-loader',
129130
],

content/how-to/set-up-hmr-with-react.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: How to Set Up Hot Module Replacement with React?
33
contributors:
44
- jmreidy
5+
- jhnns
56
---
67
Hot Module Replacement (HMR) exchanges, adds, or removes modules while an
78
application is running without a page reload.
@@ -110,14 +111,14 @@ module.exports = env => {
110111
loaders: [
111112
{ test: /\.js$/,
112113
loaders: [
113-
'babel',
114+
'babel-loader',
114115
],
115116
exclude: /node_modules/
116117
},
117118
{
118119
test: /\.css$/,
119120
loaders: [
120-
'style',
121+
'style-loader',
121122
'css-loader?modules',
122123
'postcss-loader',
123124
],

content/how-to/shim.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
---
22
title: How to Shim Third Party Libraries?
3+
contributors:
4+
- pksjce
5+
- jhnns
36
---
47

58
`webpack` as a module bundler can understand modules written as ES2015 modules, CommonJS or AMD. But many times, while using third party libraries, we see that they expect dependencies which are global aka `$` for `jquery`. They might also be creating global variables which need to be exported. Here we will see different ways to help webpack understand these __broken modules__.
@@ -48,7 +51,7 @@ module: {
4851
loaders: [
4952
{
5053
test: /[\/\\]node_modules[\/\\]some-module[\/\\]index\.js$/,
51-
loader: "imports?this=>window"
54+
loader: "imports-loader?this=>window"
5255
}
5356
]
5457
}
@@ -108,4 +111,4 @@ module: {
108111
/[\/\\]node_modules[\/\\]angular[\/\\]angular\.js$/
109112
]
110113
}
111-
```
114+
```

content/how-to/upgrade-from-webpack-1.md

Lines changed: 72 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: How to Upgrade from Webpack 1?
33
contributors:
44
- sokra
5+
- jhnns
56
---
67

78
### `resolve.root`, `resolve.fallback`, `resolve.modulesDirectories`
@@ -26,21 +27,65 @@ This option no longer requires passing an empty string. This behavior was moved
2627

2728
More stuff was changed here. Not listed in detail as it's not commonly used. See [resolving](/configuration/resolve) for details.
2829

29-
### `debug`
30+
### `module.loaders` is now `module.rules`
3031

31-
The `debug` option switched loaders to debug mode in webpack 1. This need to be passed via loader options in long-term. See loader documentation for relevant options.
32+
The old loader configuration was superseded by a more powerful rules system, which allows to configure loaders and more.
33+
For compatibility reasons the old syntax is still valid and the old names are parsed.
34+
The new naming is easier to understand to there are good reasons to upgrade the configuration.
3235

33-
The debug mode for loaders will be removed in webpack 3 or later.
36+
``` diff
37+
module: {
38+
- loaders: [
39+
+ rules: [
40+
{
41+
test: /\.css$/,
42+
- loaders: [
43+
+ use: [
44+
{
45+
loader: "style-loader"
46+
},
47+
{
48+
loader: "css-loader",
49+
- query: {
50+
+ options: {
51+
modules: true
52+
}
53+
]
54+
}
55+
]
56+
}
57+
```
3458

35-
To keep compatibility with old loaders, loaders can be switched to debug mode via plugin:
59+
### Automatic `-loader` module name extension removed
60+
61+
It is not possible anymore to omit the `-loader` extension when referencing loaders:
3662

3763
``` diff
38-
- debug: true,
39-
plugins: [
40-
+ new webpack.LoaderOptionsPlugin({
41-
+ debug: true
42-
+ })
43-
]
64+
loaders: [
65+
- "style",
66+
+ "style-loader",
67+
- "css",
68+
+ "css-loader",
69+
- "less",
70+
+ "less-loader",
71+
]
72+
```
73+
74+
See [#2986](https://github.com/webpack/webpack/issues/2986) for the reason behind this change.
75+
76+
### `module.preLoaders` and `module.postLoaders` was removed
77+
78+
``` diff
79+
module: {
80+
- preLoaders: [
81+
+ rules: [
82+
{
83+
test: /\.js$/,
84+
+ enforce: "pre",
85+
loader: "eslint-loader"
86+
}
87+
]
88+
}
4489
```
4590

4691
### `UglifyJsPlugin` sourceMap
@@ -117,7 +162,7 @@ plugins: [
117162
```
118163

119164

120-
### full dynamic requires now fail by default
165+
### Full dynamic requires now fail by default
121166

122167
A dependency with only an expression (i. e. `require(expr)`) will now create an empty context instead of an context of the complete directory.
123168

@@ -157,64 +202,35 @@ See [CLI](../api/cli).
157202

158203
These functions are now always asynchronous instead of calling their callback sync if the chunk is already loaded.
159204

160-
### `module.loaders` is now `module.rules`
161-
162-
The old loader configuration was superseded by a more powerful rules system, which allows to configure loaders and more.
205+
### `LoaderOptionsPlugin` context
163206

164-
For compatibility reasons the old syntax is still valid and the old names are parsed.
207+
Some loaders need context information and read them from the configuration. This need to be passed via loader options in long-term. See loader documentation for relevant options.
165208

166-
The new naming is easier to understand to there are good reasons to upgrade the configuration.
209+
To keep compatibility with old loaders, this information can be passed via plugin:
167210

168211
``` diff
169-
module: {
170-
- loaders: [
171-
+ rules: [
172-
{
173-
test: /\.css$/,
174-
- loaders: [
175-
+ use: [
176-
{
177-
loader: "style-loader"
178-
},
179-
{
180-
loader: "css-loader",
181-
- query: {
182-
+ options: {
183-
modules: true
184-
}
185-
]
186-
}
187-
]
188-
}
212+
plugins: [
213+
+ new webpack.LoaderOptionsPlugin({
214+
+ options: {
215+
+ context: __dirname
216+
+ }
217+
+ })
218+
]
189219
```
190220

191-
### `module.preLoaders` and `module.postLoaders` was removed
192-
193-
``` diff
194-
module: {
195-
- preLoaders: [
196-
+ rules: [
197-
{
198-
test: /\.js$/,
199-
+ enforce: "pre",
200-
loader: "eslint-loader"
201-
}
202-
]
203-
}
204-
```
221+
### `debug`
205222

206-
### `LoaderOptionPlugin` context
223+
The `debug` option switched loaders to debug mode in webpack 1. This need to be passed via loader options in long-term. See loader documentation for relevant options.
207224

208-
Some loaders need context information and read them from the configuration. This need to be passed via loader options in long-term. See loader documentation for relevant options.
225+
The debug mode for loaders will be removed in webpack 3 or later.
209226

210-
To keep compatibility with old loaders, this information can be passed via plugin:
227+
To keep compatibility with old loaders, loaders can be switched to debug mode via plugin:
211228

212229
``` diff
230+
- debug: true,
213231
plugins: [
214232
+ new webpack.LoaderOptionsPlugin({
215-
+ options: {
216-
+ context: __dirname
217-
+ }
233+
+ debug: true
218234
+ })
219235
]
220236
```

0 commit comments

Comments
 (0)