Webpack 排除特定文件 [英] Webpack Exclude a specific file
本文介绍了Webpack 排除特定文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的 webpack.config.prod.js
中有此代码,我想知道如何排除所有 json,但特定路径中的 json 除外,例如 src/configs/configs代码>
I have this code In my webpack.config.prod.js
and I was wondering how do I exclude all json except one in a specific path like src/configs/configs
exclude: [
/.html$/,
/.(js|jsx)$/,
/.css$/,
/.json$/,
/.bmp$/,
/.gif$/,
/.jpe?g$/,
/.png$/,
],
loader: require.resolve('file-loader'),
options: {
name: 'static/media/[name].[hash:8].[ext]',
}
...
推荐答案
根据 Webpack 文档,你可以这样做.
According to the Webpack documentation, you can do something like this.
exclude: {
test: [
/.html$/,
/.(js|jsx)$/,
/.css$/,
/.json$/,
/.bmp$/,
/.gif$/,
/.jpe?g$/,
/.png$/,
],
exclude: [
'src/configs/configs/your.json'
]
}
这篇关于Webpack 排除特定文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文