Skip to content

Commit 382fdc9

Browse files
authored
Merge pull request #575 from johnnyreilly/patch-1
Update migrating.md
2 parents fe790ac + 115a7b7 commit 382fdc9

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

content/guides/migrating.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ contributors:
66
- jhnns
77
- grgur
88
- domfarolino
9+
- johnnyreilly
910
---
1011

1112
## `resolve.root`, `resolve.fallback`, `resolve.modulesDirectories`
@@ -230,6 +231,55 @@ See [CLI](/api/cli).
230231

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

234+
## Loader configuration is through `options`
235+
236+
You can *no longer* configure a loader with a custom property in the `webpack.config.js`. It must be done through the `options`. The following configuration with the `ts` property is no longer valid with webpack 2:
237+
238+
```js
239+
module.exports = {
240+
...
241+
module: {
242+
use: [{
243+
test: /\.tsx?$/,
244+
loader: 'ts-loader'
245+
}]
246+
},
247+
// does not work with webpack 2
248+
ts: { transpileOnly: false }
249+
}
250+
```
251+
252+
### What are `options`?
253+
254+
Good question. Well, strictly speaking it's 2 possible things; both ways to configure a webpack loader. Classically `options` was called `query` and was a string which could be appended to the name of the loader. Much like a query string but actually with [greater powers](https://github.com/webpack/loader-utils#parsequery):
255+
256+
```js
257+
module.exports = {
258+
...
259+
module: {
260+
use: [{
261+
test: /\.tsx?$/,
262+
loader: 'ts-loader?' + JSON.stringify({ transpileOnly: false })
263+
}]
264+
}
265+
}
266+
```
267+
268+
But it can also be a separately specified object that's supplied alongside a loader:
269+
270+
```js
271+
module.exports = {
272+
...
273+
module: {
274+
use: [{
275+
test: /\.tsx?$/,
276+
loader: 'ts-loader'
277+
options: { transpileOnly: false }
278+
}]
279+
}
280+
}
281+
```
282+
233283
## `LoaderOptionsPlugin` context
234284

235285
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.

0 commit comments

Comments
 (0)