Is it possible to retrieve the serverless stage or environment in webpack.config.js, or to load different config files for different environments?
When I add this to webpack.config.js:
console.log(`bundling with webpack for environment ${process.env.NODE_ENV}`)
It turns out that NODE_ENV is undefined.
Hi @tommedema ,
you can retrieve the serverless stage within the webpack config:
const slsw = require('serverless-webpack');
const stage = slsw.lib.options.stage;
// You also have access to the whole Serverless service object too:
const serverless = slsw.lib.serverless;
So, in fact, you can access anything that is available in the serverless instance,
just like any plugin.
Excellent!
Most helpful comment
Hi @tommedema ,
you can retrieve the serverless stage within the webpack config:
So, in fact, you can access anything that is available in the serverless instance,
just like any plugin.