包括一个JSON文件作为Webpack输出,但不属于bundle.js的一部分 [英] Include a JSON file as Webpack output, but not part of bundle.js
本文介绍了包括一个JSON文件作为Webpack输出,但不属于bundle.js的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个Webpack应用,我想在运行时中读取json文件.
I have a webpack app that I'd like to read a json file in at runtime.
在webpack打包应用程序之后,我希望json文件从bundle.js中排除,但仍在package文件夹中.我该怎么办?
After webpack packages the application, I'd like the json file to be excluded from the bundle.js but still in the package folder. How can I do this?
推荐答案
我将使用 copy-webpack-plugin
只需将文件从一个位置移动到另一位置
Pretty simply moves files from one location to another
您通过向其传递一个对象将json文件移动到了目标包中:
You moved the json file into the destination package by passing it an object:
{ from: 'source', to: 'dest' }
结帐仓库以获取用法示例
这篇关于包括一个JSON文件作为Webpack输出,但不属于bundle.js的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文