mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-18 22:51:02 +00:00
feat: add build.transpile to transpile npm packages
This commit is contained in:
parent
021ba5a1e2
commit
8b0c2f1a67
@ -40,7 +40,6 @@ export default class WebpackBaseConfig {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
delete options.exclude
|
|
||||||
return options
|
return options
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,7 +139,25 @@ export default class WebpackBaseConfig {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.jsx?$/,
|
test: /\.jsx?$/,
|
||||||
exclude: this.options.build.babel.exclude,
|
exclude: file => {
|
||||||
|
// not exclude files outside node_modules
|
||||||
|
if (/node_modules/.test(file)) {
|
||||||
|
let transpile = this.options.build.transpile || []
|
||||||
|
// transpile supports string like 'vue-lib'
|
||||||
|
if (!Array.isArray(transpile)) {
|
||||||
|
transpile = [transpile]
|
||||||
|
}
|
||||||
|
// include SFCs in node_modules
|
||||||
|
transpile.push(/\.vue\.js/)
|
||||||
|
for (let pkg of transpile) {
|
||||||
|
// item in transpile can be string or regex object
|
||||||
|
if (new RegExp(pkg).test(file)) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
},
|
||||||
use: perfLoader.pool('js', {
|
use: perfLoader.pool('js', {
|
||||||
loader: 'babel-loader',
|
loader: 'babel-loader',
|
||||||
options: this.getBabelOptions()
|
options: this.getBabelOptions()
|
||||||
|
@ -61,12 +61,9 @@ export default {
|
|||||||
},
|
},
|
||||||
babel: {
|
babel: {
|
||||||
babelrc: false,
|
babelrc: false,
|
||||||
cacheDirectory: undefined,
|
cacheDirectory: undefined
|
||||||
exclude: file => (
|
|
||||||
/node_modules/.test(file) &&
|
|
||||||
!/\.vue\.js/.test(file)
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
|
transpile: [], // Name of NPM packages to be transpiled
|
||||||
vueLoader: {},
|
vueLoader: {},
|
||||||
postcss: {},
|
postcss: {},
|
||||||
templates: [],
|
templates: [],
|
||||||
|
Loading…
Reference in New Issue
Block a user