forked from serverless-heaven/serverless-webpack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompile.js
More file actions
33 lines (28 loc) · 918 Bytes
/
Copy pathcompile.js
File metadata and controls
33 lines (28 loc) · 918 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
'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;
});
},
};