我應該爲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') ]
};
};