Webpack 网页包3不排除节点_模块
这里我的webpack.config.js有什么问题,因为它无法排除节点_模块。我在以前版本的webpack中发现了类似的帖子,但由于语法不同,修复程序无法正常工作Webpack 网页包3不排除节点_模块,webpack,webpack-3,Webpack,Webpack 3,这里我的webpack.config.js有什么问题,因为它无法排除节点_模块。我在以前版本的webpack中发现了类似的帖子,但由于语法不同,修复程序无法正常工作 module.exports = { context: __dirname, entry: './src/index.js', output: { path: __dirname + '/public/assets/', publ
module.exports = {
context: __dirname,
entry: './src/index.js',
output: {
path: __dirname + '/public/assets/',
publicPath: '/assets/js/',
filename: 'bundle.js'
},
module: {
rules: [
{
test: /\.css$/,
include: /src/,
exclude: /node_modules/,
use: [
{loader: 'style-loader'},
{loader: 'css-loader'}
]
},
{
test: /\.ejs$/,
include: /src/,
exclude: /node_modules/,
use: [
{loader: 'ejs-simple-loader'}
]
},
{
test: /\.js$/,
include: /src/,
exclude: /node_modules/,
use: [
{loader: 'jshint-loader'}
]
},
{
test: /\.jsx$/,
include: /src/,
exclude: /node_modules/,
use: [
{loader: 'babel-loader'}
]
}
]
}
}
您使用的规则需要
pre
值
您的代码应为:
module.exports = {
entry: "./foo.js",
output: {
filename: "./bar.js"
},
module: {
rules: [
{
test: /\.js$/,
enforce: 'pre', // updated value
exclude: /node_modules/,
use: [
{ loader: 'jshint-loader' }
]
}
]
}
};
来源:谢谢,@robinCTS。我不明白为什么这被否决了。我复制了OPs问题,提供了解决方案,并添加了源代码。