I call webpack programmatically. At the time I call it, I have a settings object that I would like to include as a module in webpack. Is it possible?
I am looking for something similar to DefinePlugin , but I would like to define a module, not free variables.
My app.js application code is as follows:
var settings = require('settings'); console.log('Build number is', settings.buildNumber);
My webpack runner, webpack-runner.js :
var settings = { buildNumber: 100 }; // Can I pass settings into webpack config such that // app.js will be able to access it with require('settings')? var config = { entry: "./app.js", output: { path: __dirname, filename: "build.js" } }; webpack(config, function(err, stats) { console.log(stats.toString()); });
Currently, the only way I found this is to save my settings in a file, and then set an alias to the file path. But I would like to avoid saving the file just to open it in a minute.
javascript webpack dependency-management
Andrew
source share