Skip to content

jsyrjala/json-string-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Object/JSON-string loader for webpack

npm version npm downloads Known Vulnerabilities

codebeat badge

Overload imported module contents with given Object or JSON-string.

Installation

npm install json-string-loader --save-dev

Usage

In webpack.config.js:

var appConfig = {
  key: 'data'
}
...
loaders: [
  // first way: pass an object with `query`
  {
    test: /config.json$/,
    loader: 'json-string-loader?json=' + JSON.stringify(appConfig)
  },
  // second way: using `options`
  {
    test: /[^\w\.]?package.json$/,
    loader: 'json-string-loader',
    options: {
      json: appConfig
    }
  }
]

In browser:

var appConfig = require("./config.json");
// => returns {key: 'data'}

Documentation

License

MIT

About

Webpack loader for overloading imported module contents with given JSON string.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published