我尝试忽略某些json文件的导入,并使用复制插件对其进行复制。
我想忽略的导入看起来像这样:
const contract = truffleContract(require(path + name + ".json"));
webpack配置中的插件部分:
plugins: [
new webpack.IgnorePlugin(/\.json$/),
new CopyWebpackPlugin([ {from: path.resolve(__dirname, "./node_modules/myModule/ABI/"), to: "ABI"}])
]
运行webpack时,我得到以下输出:
[../../myModule/utils sync recursive ^.*\.json$] C:/Projects/myModule/utils sync ^.*\.json$ 160 bytes {main} [built]