Files
serverless-webpack/lib/wpwatch.js
T
Frank Schmid fe45384ca3 Use --webpack-use-polling to switch to fs polling mode on watch (#225)
* Use --webpack-use-polling to switch to fs pooling mode on watch

* Added unit tests
2017-09-18 16:18:19 +02:00

32 lines
773 B
JavaScript

'use strict';
const _ = require('lodash');
const BbPromise = require('bluebird');
const webpack = require('webpack');
module.exports = {
wpwatch() {
this.serverless.cli.log('Watching with Webpack...');
const watchOptions = {};
const usePolling = this.options['webpack-use-polling'];
if (usePolling) {
watchOptions.poll = _.isInteger(usePolling) ? usePolling : 3000;
this.serverless.cli.log(`Enabled polling (${watchOptions.poll} ms)`);
}
const compiler = webpack(this.webpackConfig);
compiler.watch(watchOptions, (err, stats) => {
if (err) {
throw err;
}
if (stats) {
console.log(stats.toString()); // eslint-disable-line no-console
}
});
return BbPromise.resolve();
},
};