Skip to content

Commit

Permalink
Add ability to run Webpack in series (#44)
Browse files Browse the repository at this point in the history
* Add ability to run webpack in series

* Use console.log instead of sls.cli.log

* Fix ESLint errors

* Reduce webpack configurations with ramda
  • Loading branch information
TimonVS authored and jogold committed Feb 16, 2018
1 parent 76311df commit 97c667a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ By default the plugin will look for a `webpack.config.js` in the service root. Y
custom:
webpack:
config: ./path/to/config/file.js
series: true # run Webpack in series, useful for large projects. Defaults to false.
```

The `entry` and `output` objects are set by the plugin.
Expand Down
4 changes: 3 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ class ServerlessPluginWebpack {
// Include bundle at function level
this.serverless.service.functions = service.setFnsPackage(this.serverless.service.functions);

const runWebpack = this.custom.series ? wpack.runSeries : wpack.run;

// Run webpack
return wpack.run(wpack.createConfigs(
return runWebpack(wpack.createConfigs(
this.originalFunctions,
webpackConfig,
this.originalServicePath,
Expand Down
6 changes: 6 additions & 0 deletions src/lib/wpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,13 @@ const run = configs =>
});
});

/**
* Runs webpack with an array of configurations in series
*/
const runSeries = R.reduce((promise, config) => promise.then(() => run(config)), Promise.resolve());

module.exports = {
createConfigs,
run,
runSeries,
};

0 comments on commit 97c667a

Please sign in to comment.