serverless-webpack icon indicating copy to clipboard operation
serverless-webpack copied to clipboard

Respect the webpack config watch: false

Open matthew-gladman-oua opened this issue 2 years ago • 0 comments

This is a Feature Proposal

Description

It would be very effective if serverless-webpack respected the Webpack configuration for watch, this would make it not only consistent but easy to disable watch dynamically on a large number of serverless packages. Alternatively being able to disable watch via an env variable would also be pretty good.

Example implementations:

// wpwatch.js
if (this.webpackConfig.watch === false) {
   // If we do not watch we will just run an ordinary compile
   if (!this.log) {
     this.serverless.cli.log('Watch disabled by Webpack.');
   }
   return this.serverless.pluginManager.spawn('webpack:compile');
}

and / or

// wpwatch.js
if (process.env.CI) {
   // If we do not watch we will just run an ordinary compile
   if (!this.log) {
     this.serverless.cli.log('Watch disabled by detecting CI environment.');
   }
   return this.serverless.pluginManager.spawn('webpack:compile');
}

This would be useful for us, and potentially others that are also running many serverless offlines in a CI environment for integration tests, but adding in the --webpack-no-watch to serverless offline adds a lot of extra npm scripts for just the CI environment, this lets devs disable it globally without touching the npm scripts.

It also makes it less confusing on why watching isn't properly being disabled.

Similar or dependent issue(s):

  • N/A

Additional Data

  • Serverless-Webpack Version you're using: 5.6.1
  • Webpack version you're using: 4
  • Serverless Framework Version you're using: v2
  • Operating System: Linux
  • Stack Trace (if available): N/A

matthew-gladman-oua avatar Apr 13 '22 01:04 matthew-gladman-oua