json-loader
json-loader
Install
npm install --save-dev json-loader
⚠️ Note: Since webpack v2, importing of JSON files will work by default. You might still want to use this if you use a custom file extension.
Usage
Configuration (recommended)
webpack.config.js
module.exports = { module: { rules: [ { test: /\.json$/, use: 'json-loader' } ] } }
import json from 'file.json';
CLI
webpack --module-bind 'json=json-loader'
import json from 'file.json';
Inline
import json from 'json-loader!file.json';
© JS Foundation and other contributors
Licensed under the Creative Commons Attribution License 4.0.
https://webpack.js.org/loaders/json-loader