Files
serverless-webpack/lib/prepareOfflineInvoke.js
Joseph Lee Hunsaker 5c9f14d53f Make serverless-webpack more extensible (#254)
* Make serverless-webpack more extensible

Use PluginManager to make serverless-webpack more extensible 

Following the advice from serverless blog on Advanced Plugin Development. https://serverless.com/blog/advanced-plugin-development-extending-the-core-lifecycle/

* use sublifecycle with webpack command

* Use new lifecycles and adapt unit tests

* Fixed unit test after merge

* Use new events everywhere

* Added section to README
2017-10-23 15:29:17 +02:00

28 lines
787 B
JavaScript

'use strict';
const _ = require('lodash');
const path = require('path');
/**
* Special settings for use with serverless-offline.
*/
module.exports = {
prepareOfflineInvoke() {
// Use service packaging for compile
_.set(this.serverless, 'service.package.individually', false);
return this.serverless.pluginManager.spawn('webpack:validate')
.then(() => {
// Set offline location automatically if not set manually
if (!this.options.location && !_.get(this.serverless, 'service.custom.serverless-offline.location')) {
_.set(this.serverless, 'service.custom.serverless-offline.location',
path.relative(this.serverless.config.servicePath, path.join(this.webpackOutputPath, 'service'))
);
}
return null;
});
}
};