json loader module for webpack
JavaScript

README.md

npm node deps chat

JSON Loader

Note: Since webpack v2, JSON files will work by default. You might still want to use this if you use a custom file extension.

Install

npm install --save-dev json-loader

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';

Options

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').

Maintainer


Tobias Koppers

Juho Vepsäläinen

Joshua Wiens

Kees Kluskens

Sean Larkin