【发布时间】:2017-12-01 01:24:45
【问题描述】:
我应该为 WebPack 中的各种加载器包含还是排除 node_modules?
我在各种加载器(JS、TS、CSS、SCSS、文件、 url、raw 等)
我不明白你为什么要或不包括它。显然它会引入代码并将其包含在输出构建中,我猜这只是加载器是否处理它。我只遇到过一个节点模块,如果加载器处理了它,它就不能工作,到目前为止,还没有一个不能以一种或另一种方式工作的节点模块。
除了一个包之外,其他包似乎都不在乎它们是包含还是排除。它对输出/浏览器有什么影响?
例如:
'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') ]
};
};
【问题讨论】:
标签: webpack loader webpack-2 babeljs