You've already forked serverless-webpack
mirror of
https://github.com/encounter/serverless-webpack.git
synced 2026-03-30 11:37:58 -07:00
34 lines
918 B
JavaScript
34 lines
918 B
JavaScript
'use strict';
|
|
|
|
const BbPromise = require('bluebird');
|
|
const webpack = require('webpack');
|
|
|
|
module.exports = {
|
|
compile() {
|
|
this.serverless.cli.log('Bundling with Webpack...');
|
|
|
|
const compiler = webpack(this.webpackConfig);
|
|
|
|
return BbPromise
|
|
.fromCallback(cb => compiler.run(cb))
|
|
.then(stats => {
|
|
|
|
this.serverless.cli.consoleLog(stats.toString({
|
|
colors: true,
|
|
hash: false,
|
|
version: false,
|
|
chunks: false,
|
|
children: false
|
|
}));
|
|
if (stats.compilation.errors.length) {
|
|
throw new Error('Webpack compilation error, see above');
|
|
}
|
|
const outputPath = stats.compilation.compiler.outputPath;
|
|
this.webpackOutputPath = outputPath;
|
|
this.originalServicePath = this.serverless.config.servicePath;
|
|
this.serverless.config.servicePath = outputPath;
|
|
return stats;
|
|
});
|
|
},
|
|
};
|