webpack loaders中的include/exclude有什么用?
本文介绍了webpack loaders中的include/exclude有什么用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
在看webpack配置文件时候,其中loaders下,有时候配置include和exclude,这两个参数有什么用呢?如果不配置会有什么影响?
比如我经常看到有写exclude: /node_modules/
的,这么做的目的何在?
{
module: {
loaders: [{
test: /\.js$/,
loader: 'babel-loader',
include: [
path.resolve(__dirname, "app/src"),
path.resolve(__dirname, "app/test")
],
exclude: /node_modules/
}]
}
}
解决方案
include 表示哪些目录中的 .js 文件需要进行 babel-loader
exclude 表示哪些目录中的 .js 文件不要进行 babel-loader
https://webpack.js.org/configuration/
如果想要排除 node_modules
目录可以参考
http://stackoverflow.com/questions/33001237/webpack-not-excluding-node-modules
这篇关于webpack loaders中的include/exclude有什么用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文