我正在构建一个 Node 框架,使用的是 webpack (不可否认,我可能应该使用 Gulp)。当我包含 EJS 模块时,webpack 将它包含在编译后的源代码中,尽管我明确告诉它排除 node _ module 目录。
module.exports = {
context: __dirname,
target: 'node',
// ...
output: {
libraryTarget: 'commonjs'
// ...
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader?{ "stage": 0, "optional": ["runtime"] }'
}
]
}
};
正如您所看到的,我有一个 JS 文件测试,我告诉它排除 node _ module; 为什么它忽略我的排除呢?