我应该为WebPack中的各种加载器包含或排除node_modules吗? (JS,TS,CSS,SCSS,文件)明确地排除它(通过排除node_modules或只包括src或客户端文件夹)的一些配置隐藏地包括它的一些配置,网址,原始等)WebPack加载程序配置:排除或包含node_modules?
我不明白为什么你会或不会包括它。显然,它带来了代码,并以任何方式将它包含在输出构建中,我猜测这只是加载器是否处理它。我只遇到一个节点模块,如果加载器处理了它,那么它不起作用,到目前为止,没有其他方式不以这种或那种方式工作。
除了一个软件包外,其他人似乎都不关心它们是否被包含或排除。它与输出/浏览器有什么不同?
例如:
'use strict';
const path = require('path');
module.exports = (root) => {
return {
// BABEL LOADER
// Reference: https://github.com/babel/babel-loader
// Transpile .js files using babel-loader
// Compiles ES6 and ES7 into ES5 code
// Run on .js files
test: /\.js$/,
// Use the babel-loader
use: [
// Babel transpiler, see .babelrc for configuration
{
loader: 'babel-loader',
options: {
sourceMap: true, // Emit sourcemaps
cacheDirectory: true // Cache compilation
}
}
],
// Aside from one package, none of the others seem to care if they're included or excluded.
include: [ path.resolve(root, 'client') ]
};
};