From b2aa4d46b8282df5ae9df34c8103321d99d347c9 Mon Sep 17 00:00:00 2001 From: Cyrille Chopelet Date: Wed, 3 Jan 2018 20:37:58 +0100 Subject: [PATCH] Review Webpack configuration Fix configuration for local serving (opening browser fails on Ubuntu) Ensure the packaging links are OK --- config/index.js | 2 +- gulp/webpack.dev.conf.js | 11 ++++++++++- gulp/webpack.prod.conf.js | 5 ++--- index.html | 2 -- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/config/index.js b/config/index.js index 1cdeea5..2f96bb3 100644 --- a/config/index.js +++ b/config/index.js @@ -24,7 +24,7 @@ module.exports = { dev: { env: require('./dev.env'), port: 8080, - autoOpenBrowser: true, + autoOpenBrowser: false, assetsSubDirectory: 'static', assetsPublicPath: '', proxyTable: {}, diff --git a/gulp/webpack.dev.conf.js b/gulp/webpack.dev.conf.js index fdfd804..e16f7e2 100644 --- a/gulp/webpack.dev.conf.js +++ b/gulp/webpack.dev.conf.js @@ -3,6 +3,7 @@ const webpack = require('webpack') const config = require('../config') const merge = require('webpack-merge') const baseWebpackConfig = require('./webpack.base.conf') +const CopyWebpackPlugin = require('copy-webpack-plugin') const HtmlWebpackPlugin = require('html-webpack-plugin') const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin') @@ -32,8 +33,16 @@ module.exports = lg => { new HtmlWebpackPlugin({ filename: 'index.html', template: 'index.html', - inject: false + inject: true }), + // copy custom static assets + new CopyWebpackPlugin([ + { + from: utils.resolve('static'), + to: config.build.assetsSubDirectory, + ignore: ['.*'] + } + ]), new FriendlyErrorsPlugin() ] }) diff --git a/gulp/webpack.prod.conf.js b/gulp/webpack.prod.conf.js index 0ca28db..f70ee05 100644 --- a/gulp/webpack.prod.conf.js +++ b/gulp/webpack.prod.conf.js @@ -1,4 +1,3 @@ -const path = require('path') const utils = require('./utils') const webpack = require('webpack') const config = require('../config') @@ -59,7 +58,7 @@ module.exports = lg => { ? 'index.html' : config.build.index, template: 'index.html', - inject: false, + inject: true, minify: { removeComments: true, collapseWhitespace: true, @@ -93,7 +92,7 @@ module.exports = lg => { // copy custom static assets new CopyWebpackPlugin([ { - from: path.resolve(__dirname, '../static'), + from: utils.resolve('static'), to: config.build.assetsSubDirectory, ignore: ['.*'] } diff --git a/index.html b/index.html index eda92b2..eb4a641 100644 --- a/index.html +++ b/index.html @@ -7,7 +7,6 @@ -