npm install --save-dev json-loader
webpack.config.js
module.exports = { module: { rules: [ { test: /\.json$/, use: 'json-loader' } ] } }
import json from 'file.json';
webpack --module-bind 'json=json-loader'
import json from 'file.json';
import json from 'json-loader!file.json';
stringify
By default, the json-loader will output the json object, set this query parameter to 'true' can output the json object as a string, e.g. require('json-loader?stringify!../index.json')
.
© 2012–2016 Tobias Koppers
Licensed under the Creative Commons Attribution License 4.0.
https://webpack.js.org/loaders/json-loader/