自从我升级到Webpack 2后,我无法排除"排除"在我的"规则"。无法通过"排除"进入"选项"无论是。现在做正确的方法是什么?
之前:
plot(df$First, df$Measurement, pch=20, xlim=c(250,270),
xlab="Time", ylab="Measurement")
points(df$Last, df$Measurement, pch=20)
segments(df$First, df$Measurement, df$Last, df$Measurement)
现在:
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
}
整个配置:
{
test: /\.js$/,
use: [{ loader: 'babel-loader' }]
???
}
答案 0 :(得分:7)
只需使用
module: {
rules: [
{
test: /\.jsx?$/,
include: [
path.resolve(__dirname, "app")
],
exclude: [
path.resolve(__dirname, "app/demo-files")
]
}
]
}
答案 1 :(得分:4)
这就是我们遇到同样问题的方法
{
test: /\.js$/,
use: [{
loader: 'babel-loader',
options: {
ignore: '/node_modules/'
}
}]
}
答案 2 :(得分:1)
exclude
中的webpack 2
属性仍然与您展示的相同,但没有尝试过,它的工作原理只有
module: {
loaders: [
{
test: /\.jsx?/,
loader: 'babel-loader',
exclude: [/node_modules/]
},
{
test: /\.(jpg|png|gif|eot|woff2|woff|ttf|ico|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'url-loader'
},
{
test: /\.(js)$/,
loader: `babel-loader`,
exclude: [/node_modules/]
}]
}
答案 3 :(得分:1)
您是否考虑过在webpack.config.js中使用 externals 来忽略目录,在您的情况下是" node_modules"
https://webpack.js.org/guides/author-libraries/#external-limitations