json-string-loader
v1.1.0
Published
Webpack loader for overloading imported module contents with given Object/JSON-string.
Downloads
263
Maintainers
Readme
Object/JSON-string loader for webpack
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'}