mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-30 09:27:13 +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
|
||||
}
|
||||
|
||||
@ -140,7 +139,25 @@ export default class WebpackBaseConfig {
|
||||
},
|
||||
{
|
||||
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', {
|
||||
loader: 'babel-loader',
|
||||
options: this.getBabelOptions()
|
||||
|
@ -61,12 +61,9 @@ export default {
|
||||
},
|
||||
babel: {
|
||||
babelrc: false,
|
||||
cacheDirectory: undefined,
|
||||
exclude: file => (
|
||||
/node_modules/.test(file) &&
|
||||
!/\.vue\.js/.test(file)
|
||||
)
|
||||
cacheDirectory: undefined
|
||||
},
|
||||
transpile: [], // Name of NPM packages to be transpiled
|
||||
vueLoader: {},
|
||||
postcss: {},
|
||||
templates: [],
|
||||
|
Loading…
Reference in New Issue
Block a user