Use webpack-dev-server instead of http-server

Advantages:
 * blocks while a rebuild is in progress so you're less likely to reload the
   old version

 * serves from memory rather than disk, so we no longer need to turn off the
   cachebuster to avoid filling the disk with bundles. Empirically, seems to
   last a plausible amount of time without OOMing; there's no real reason to
   believe it would use any more memory than webpack itself.

 * That in turn means we no longer need the hack to stop chrome caching old
   sourcemaps (because the sourcemap now has a cachebuster in its name).

 * one fewer process for parallelshell to (fail to) manage.

 * in future, we could consider the fancy hot-reload functionality.
This commit is contained in:
Richard van der Hoff 2016-11-03 14:58:30 +00:00
parent 4dab36d3b2
commit ff462580b0
2 changed files with 15 additions and 19 deletions

View file

@ -3,15 +3,6 @@ var webpack = require('webpack');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var HtmlWebpackPlugin = require('html-webpack-plugin');
var cachebuster = true;
for (var i=0; i < process.argv.length; i++) {
var arg = process.argv[i];
if (arg == "--no-cache-buster") {
cachebuster = false;
}
}
module.exports = {
entry: {
"bundle": "./src/vector/index.js",
@ -49,7 +40,7 @@ module.exports = {
},
output: {
path: path.join(__dirname, "vector"),
filename: "[name]" + (cachebuster ? ".[chunkhash]" : "") + ".js",
filename: "[name].[chunkhash].js",
devtoolModuleFilenameTemplate: function(info) {
// Reading input source maps gives only relative paths here for
// everything. Until I figure out how to fix this, this is a
@ -84,7 +75,7 @@ module.exports = {
}),
new ExtractTextPlugin(
"[name]" + (cachebuster ? ".[contenthash]" : "") + ".css",
"[name].[contenthash].css",
{
allChunks: true
}
@ -100,7 +91,13 @@ module.exports = {
inject: false,
}),
],
devtool: 'source-map'
devtool: 'source-map',
// configuration for the webpack-dev-server
devServer: {
// serve unwebpacked assets from vector.
contentBase: './vector',
},
};
// olm is an optional dependency. Ignore it if it's not installed, to avoid a