-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathbundler.js
52 lines (42 loc) · 1.45 KB
/
bundler.js
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
var Webpack = require('webpack');
var WebpackDevServer = require('webpack-dev-server');
var webpackConfig = require('./webpack.config.js');
var path = require('path');
var fs = require('fs');
var host = process.env.APP_HOST || 'localhost';
module.exports = function () {
// First we fire up Webpack an pass in the configuration we
// created
var bundleStart = null;
var compiler = Webpack(webpackConfig);
// We give notice in the terminal when it starts bundling and
// set the time it started
compiler.plugin('compile', function() {
console.log('Bundling...');
bundleStart = Date.now();
});
// We also give notice when it is done compiling, including the
// time it took. Nice to have
compiler.plugin('done', function() {
console.log('Bundled in ' + (Date.now() - bundleStart) + 'ms!');
});
var bundler = new WebpackDevServer(compiler, {
// We need to tell Webpack to serve our bundled application
// from the assets path. When proxying:
// http://localhost:3000/assets -> http://localhost:8080/assets
publicPath: '/assets/',
// Configure hot replacement
hot: true,
// The rest is terminal configurations
quiet: false,
noInfo: true,
stats: {
colors: true
}
});
// We fire up the development server and give notice in the terminal
// that we are starting the initial bundle
bundler.listen(3001, host, function () {
console.log('Bundling project, please wait...');
});
};