这里我的webpack.config.js有什么问题,因为它无法排除node_modules。我在以前版本的webpack中发现了关于这个问题的类似帖子,但是由于语法不同,修复不起作用...
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'}
]
}
]
}
}
1条答案
按热度按时间jchrr9hc1#
您正在使用需要
pre
值的规则。你的代码应该是:
来源:https://webpack.js.org/configuration/module/#ruleenforce