Skip to content

Commit 3b0adb0

Browse files
authored
Update migrating.md
Added details of loader configuration - I did this on a phone so it might not be perfect...
1 parent 48546b6 commit 3b0adb0

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

content/guides/migrating.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,55 @@ See [CLI](/api/cli).
230230

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

233+
## Loader configuration is through `options`
234+
235+
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:
236+
237+
```js
238+
module.exports = {
239+
...
240+
module: {
241+
use: [{
242+
test: /\.tsx?$/,
243+
loader: 'ts-loader'
244+
}]
245+
},
246+
// does not work with webpack 2
247+
ts: { transpileOnly: false }
248+
}
249+
```
250+
251+
### What is options?
252+
253+
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):
254+
255+
```js
256+
module.exports = {
257+
...
258+
module: {
259+
use: [{
260+
test: /\.tsx?$/,
261+
loader: 'ts-loader?' + JSON.stringify({ transpileOnly: false })
262+
}]
263+
}
264+
}
265+
```
266+
267+
But it can also be a separately specified object that's supplied alongside a loader:
268+
269+
```js
270+
module.exports = {
271+
...
272+
module: {
273+
use: [{
274+
test: /\.tsx?$/,
275+
loader: 'ts-loader'
276+
options: { transpileOnly: false }
277+
}]
278+
}
279+
}
280+
```
281+
233282
## `LoaderOptionsPlugin` context
234283

235284
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)