Configuration of Babel can be done via `.babelrc` or `babel-loader` options.
### Excluding node_modules
It is common to have `exclude: /node_modules/` for JS transpilation rules (e.g. `babel-loader`) that apply to `.js` files. Due to the inference change of v15, if you import a Vue SFC inside `node_modules`, its `<script>` part will be excluded from transpilation as well.
In order to ensure JS transpilation is applied to Vue SFCs in `node_modules`, you need to whitelist them by using an exclude function instead:
@@ -57,6 +57,23 @@ The benefit is that this same rule also applies to plain `*.less` imports from J
v15 also allows using non-serializable options for loaders, which was not possible in previous versions.
### Importing SFCs from Dependencies
It is common to have `exclude: /node_modules/` for JS transpilation rules (e.g. `babel-loader`) that apply to `.js` files. Due to the inference change of v15, if you import a Vue SFC inside `node_modules`, its `<script>` part will be excluded from transpilation as well.
In order to ensure JS transpilation is applied to Vue SFCs in `node_modules`, you need to whitelist them by using an exclude function instead:
``` js
{
test:/\.js$/,
loader:'babel-loader',
exclude:file=>(
/node_modules/.test(file)&&
!/\.vue\.js/.test(file)
)
}
```
### Template Preprocessing
v14 and below uses [consolidate](https://github.com/tj/consolidate.js/) to compile `<template lang="xxx">`. v15 now applies preprocessing for them using webpack loaders instead.