我想使用exclude忽略某些目录以进行编译,但是在Vue Cli3中,它不起作用。我的选择是:
chainWebpack: config => {
config.module
.rule('js')
.test(/\.jsx?$/)
.use('babel-loader')
.loader('babel-loader')
.exclude
.add(resolve('src/libs/iview')) // this line not work
.end();
}
错误:
TypeError: Cannot read property 'add' of undefined
答案 0 :(得分:1)
要从Babel转换中排除文件,可以对js babel-loader使用excludes选项。下面是一个示例。
注意事项:
/first/js/chunk-vendors.deb8a740.js
命令// const path = require('path') // somewhere at the top of the file...
chainWebpack: config => {
config.module
.rule('js')
.exclude
.add(/path\/to\/folder\/.+\.ignore/) // Regexp: ignore anything inside of path/to/folder that has .ignore in the file extension
// .add(path.resolve('./path/to/the/folder')) // example with a nix folder
// .add('C:\\path\\to\\the\\folder\\') // absolute path, example with a Windows folder
.end()
}
将返回:
vue inspect module.rules
答案 1 :(得分:0)
只需删除此内容:
.use('babel-loader')
.loader('babel-loader')
它有效。