简体   繁体   English

Brpack.io中是否有某种JS​​ON加载器与Webpack中的方式相同?

[英]Is there some kind of JSON loader for Brunch.io the way there is in Webpack?

Using Webpack "loaders", I can "require" a JSON file using a plugin/loader. 使用Webpack“加载器”,我可以使用插件/加载器“需要”一个JSON文件。 Something like, 就像是,

var myData = require('!json!./dataFile.json');

This way I can access many different JSON files in my js modules without having to make http requests or manually paste the data into a js file. 这样我就可以在我的js模块中访问许多不同的JSON文件,而无需发出http请求或手动将数据粘贴到js文件中。

Is there any plugin like this for Brunch, or a different way of obtaining the same result? Brunch是否有这样的插件,或获得相同结果的不同方式?

Use the plugin: npm i -S json-brunch 使用插件: npm i -S json-brunch

Then, simply put json files into app directory and require them: require("file.json"). 然后,只需将json文件放入app目录并要求它们:require(“file.json”)。 Done. 完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM