test: fix exclude for cli-service dynamic entries

This commit is contained in:
Evan You
2018-05-03 19:06:22 -04:00
parent 3139228008
commit 65910a05db
+9 -4
View File
@@ -4,6 +4,7 @@ module.exports = (api, {
}) => {
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
@@ -11,14 +12,18 @@ module.exports = (api, {
.test(/\.jsx?$/)
.exclude
.add(filepath => {
// check if this is something the user explicitly wants to transpile
if (transpileDependencies.some(dep => filepath.match(dep))) {
return false
}
// 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)
})