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

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

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部