diff options
author | Vitaly Takmazov | 2018-09-20 21:45:22 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2023-01-13 10:37:53 +0300 |
commit | bec0aef574b7e92b7862bb5292238304429d10a1 (patch) | |
tree | 3b4754b0b888fb4fddc0100ac3d68f9cc0398b60 /vnext/webpack.config.js | |
parent | ff3948c9b170d5e9e286ca2734e3c9657c18c489 (diff) |
welcome back, cli and dev-server
Diffstat (limited to 'vnext/webpack.config.js')
-rw-r--r-- | vnext/webpack.config.js | 33 |
1 files changed, 13 insertions, 20 deletions
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 } -}; +} |