webpack-contrib / json-loader

json loader module for webpack - UNMAINTAINED

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Alternative installation method

Reggino opened this issue · comments

Thank you for this!

Since node 5 it is possible to just require .json files (see discussion e.g. webpack/webpack#184 and https://github.com/nodejs/node-v0.x-archive/blob/master/lib/module.js#L485 )

To reflect that, it would be nice if the README.md could point out that the same syntax (require('sample.json')) can be used, using this loader by adding

  module: {
    loaders: [
    {
      test: /\.json$/,
      loader: 'json'
    }]
  }

to your Webpack configuration file. It took me a while to figure that out while require-ing node 5 modules.

Small correction here:

Node’s native JSON loading was possible even within 0.10.x releases.

PR welcome. Note that this is also somewhat related to #7.

Closing since to use json in webpack, you still need json-loader.