Files
vue-cli/packages/@vue/cli-plugin-babel/index.js
T
Evan You f5c0f58673 feat: upgrade to vue-loader 15
BREAKING CHANGE: the "vueLoader" option has been removed. To modify vue-loader
options, use chainWebpack then `config.module.rule(vue).use(vue-loader).tap()`.
vue-loader has been upgraded to v15 and expects different options from v14.
2018-05-04 18:58:11 -04:00

47 lines
1.3 KiB
JavaScript

module.exports = (api, {
parallel,
transpileDependencies
}) => {
const useThreads = process.env.NODE_ENV === 'production' && parallel
const cacheDirectory = api.resolve('node_modules/.cache/cache-loader')
const cliServicePath = require('path').dirname(require.resolve('@vue/cli-service'))
api.chainWebpack(webpackConfig => {
const jsRule = webpackConfig.module
.rule('js')
.test(/\.jsx?$/)
.exclude
.add(filepath => {
// always trasnpile js in vue files
if (/\.vue\.jsx?$/.test(filepath)) {
return false
}
// exclude dynamic entries from cli-service
if (filepath.startsWith(cliServicePath)) {
return true
}
// check if this is something the user explicitly wants to transpile
if (transpileDependencies.some(dep => filepath.match(dep))) {
return false
}
// Don't transpile node_modules
return /node_modules/.test(filepath)
})
.end()
.use('cache-loader')
.loader('cache-loader')
.options({ cacheDirectory })
.end()
if (useThreads) {
jsRule
.use('thread-loader')
.loader('thread-loader')
}
jsRule
.use('babel-loader')
.loader('babel-loader')
})
}