Leo*_*ban 4 javascript ecmascript-6 webpack-2
我需要让babel运行/node_modules/identicons/然而我仍然想要排除所有其他包.
原因是identicons包使用模板字符串并在运行时中断
"webpack -p"
有问题的字符串(node_modules/identicons/index.js):
str += `<rect x="${x}" y="${y}" width="${xside}" height="${xside}" style="fill:${color}" />`
Run Code Online (Sandbox Code Playgroud)
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
//include: /node_modules/identicons/,
use: ["babel-loader"]
},
Run Code Online (Sandbox Code Playgroud)
如何写出这种模式?
我认为你可以使用正则表达式
exclude: [
/node_modules\/(?!identicons).*/
]
Run Code Online (Sandbox Code Playgroud)
其他方式:
exclude: [
{
test: [
path.resolve(__dirname, './node_modules'),
],
exclude: [
path.resolve(__dirname, './node_modules/MODULE_TO_INCLUDE'),
path.resolve(__dirname, './node_modules/ANOTHER_MODULE_TO_INCLUDE'),
]
}
]
Run Code Online (Sandbox Code Playgroud)
这对我有用。
| 归档时间: |
|
| 查看次数: |
3849 次 |
| 最近记录: |