From bec0aef574b7e92b7862bb5292238304429d10a1 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 20 Sep 2018 21:45:22 +0300 Subject: welcome back, cli and dev-server --- vnext/webpack.config.js | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) (limited to 'vnext/webpack.config.js') diff --git a/vnext/webpack.config.js b/vnext/webpack.config.js index 7529c592..f040c261 100644 --- a/vnext/webpack.config.js +++ b/vnext/webpack.config.js @@ -5,13 +5,12 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin'); const ErrorOverlayPlugin = require('error-overlay-webpack-plugin'); -const history = require('connect-history-api-fallback'); -const convert = require('koa-connect'); -const internalIp = require('internal-ip'); + +const dev = process.env.NODE_ENV !== 'production'; module.exports = { - devtool: process.env.WEBPACK_SERVE ? 'source-map' : false, - mode: process.env.WEBPACK_SERVE ? 'development' : 'production', + devtool: dev ? 'source-map' : false, + mode: dev ? 'development' : 'production', entry: { 'Juick': [ __dirname + '/src/index.js', @@ -19,8 +18,8 @@ module.exports = { ] }, output: { - filename: process.env.WEBPACK_SERVE ? '[name].js' : '[name].[contenthash].bundle.js', - chunkFilename: process.env.WEBPACK_SERVE ? '[name].js' : '[name].[contenthash].bundle.js', + filename: dev ? '[name].js' : '[name].[contenthash].bundle.js', + chunkFilename: dev ? '[name].js' : '[name].[contenthash].bundle.js', publicPath: '/', path: path.resolve(__dirname, 'dist') }, @@ -71,7 +70,7 @@ module.exports = { new UglifyJsPlugin({ cache: true, parallel: true, - sourceMap: Boolean(process.env.WEBPACK_SERVE) + sourceMap: dev }), new OptimizeCSSAssetsPlugin({}) ], @@ -107,18 +106,12 @@ module.exports = { template: './src/views/index.html', filename: './index.html' }), + new webpack.HotModuleReplacementPlugin(), new ErrorOverlayPlugin() ], -}; - -module.exports.serve = { - content: [__dirname], - host: internalIp.v4.sync(), - add: (app, middleware, options) => { - const historyOptions = { - // ... see: https://github.com/bripkens/connect-history-api-fallback#options - }; - - app.use(convert(history(historyOptions))); + devServer: { + bonjour: true, + historyApiFallback: true, + hot: true } -}; +} -- cgit v1.2.3