Substitute loader for webpack
Replaces the content of a file. Defaults to null
but you can supply the new content as parameter.
$ npm i -S substitute-loader
module: {
loaders: [ {
test: /\.mock.json$/,
// default
loader: "substitute"
// custom content
// loader: "substitute?{content: '{}'}"
} ]
}
// default, mock will equal null
var emptyMock = require("substitute!./mock.json");
// custom, mock will equal "{}"
var emptyMock = require("substitute!./mock.json?" + JSON.stringify({}));