admin管理员组文章数量:1291264
I want to import .geojson
file extension just like .json
files (I don't need any special parsing).
as I seen in webpack docs:
Since webpack >= v2.0.0, importing of JSON files will work by default. You might still want to use this if you use a custom file extension. See the v1.0.0 -> v2.0.0 Migration Guide for more information
but when I switch documentation version to webpack 5, there is no more content about this solution.
what is best practice to have .geojson
files without downloading any extra module
I want to import .geojson
file extension just like .json
files (I don't need any special parsing).
as I seen in webpack docs:
Since webpack >= v2.0.0, importing of JSON files will work by default. You might still want to use this if you use a custom file extension. See the v1.0.0 -> v2.0.0 Migration Guide for more information
but when I switch documentation version to webpack 5, there is no more content about this solution.
what is best practice to have .geojson
files without downloading any extra module
-
Try reading the file using the
fs
module, then use something likeJSON.parse
– kerolloz Commented Mar 1, 2022 at 7:01 - @kerolloz does it helps for bundling? I want to host my final project in a web server – memeso Commented Mar 1, 2022 at 7:07
1 Answer
Reset to default 8In webpack 5 we can use "Asset Modules" to load mon files like "json", "png" etc. See for more info: https://webpack.js/guides/asset-modules/
The loader config for your case might looks like this:
{
test: /\.geojson$/,
type: 'json',
}
本文标签: javascriptneed for json loader in webpack 5Stack Overflow
版权声明:本文标题:javascript - need for json loader in webpack 5 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741526662a2383508.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论