From d36fc79d7e6419ecc8e412f181b074f56af31009 Mon Sep 17 00:00:00 2001 From: wangweicong Date: Wed, 11 Sep 2019 11:16:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Edemo=20dev=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/webpack.dev.demo.conf.js | 26 +++++++++++------------ config/index.js | 38 ++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 13 deletions(-) diff --git a/build/webpack.dev.demo.conf.js b/build/webpack.dev.demo.conf.js index f53c4b2..74a1fec 100644 --- a/build/webpack.dev.demo.conf.js +++ b/build/webpack.dev.demo.conf.js @@ -18,33 +18,33 @@ const devWebpackConfig = merge(baseWebpackConfig, { app: './examples/main.js' }, module: { - rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap, usePostCSS: true }) + rules: utils.styleLoaders({ sourceMap: config.demo.cssSourceMap, usePostCSS: true }) }, // cheap-module-eval-source-map is faster for development - devtool: config.dev.devtool, + devtool: config.demo.devtool, // these devServer options should be customized in /config/index.js devServer: { clientLogLevel: 'warning', historyApiFallback: { rewrites: [ - { from: /.*/, to: path.posix.join(config.dev.assetsPublicPath, 'index.html') }, + { from: /.*/, to: path.posix.join(config.demo.assetsPublicPath, 'index.html') }, ], }, hot: true, contentBase: false, // since we use CopyWebpackPlugin. compress: true, - host: HOST || config.dev.host, - port: PORT || config.dev.port, - open: config.dev.autoOpenBrowser, - overlay: config.dev.errorOverlay + host: HOST || config.demo.host, + port: PORT || config.demo.port, + open: config.demo.autoOpenBrowser, + overlay: config.demo.errorOverlay ? { warnings: false, errors: true } : false, - publicPath: config.dev.assetsPublicPath, - proxy: config.dev.proxyTable, + publicPath: config.demo.assetsPublicPath, + proxy: config.demo.proxyTable, quiet: true, // necessary for FriendlyErrorsPlugin watchOptions: { - poll: config.dev.poll, + poll: config.demo.poll, } }, plugins: [ @@ -64,7 +64,7 @@ const devWebpackConfig = merge(baseWebpackConfig, { new CopyWebpackPlugin([ { from: path.resolve(__dirname, '../static'), - to: config.dev.assetsSubDirectory, + to: config.demo.assetsSubDirectory, ignore: ['.*'] } ]) @@ -72,7 +72,7 @@ const devWebpackConfig = merge(baseWebpackConfig, { }) module.exports = new Promise((resolve, reject) => { - portfinder.basePort = process.env.PORT || config.dev.port + portfinder.basePort = process.env.PORT || config.demo.port portfinder.getPort((err, port) => { if (err) { reject(err) @@ -88,7 +88,7 @@ module.exports = new Promise((resolve, reject) => { // messages: [`Your application is running here: http://${devWebpackConfig.devServer.host}:${port}`], messages: [`Your application is running here: http://localhost:${port}`], }, - onErrors: config.dev.notifyOnErrors + onErrors: config.demo.notifyOnErrors ? utils.createNotifierCallback() : undefined })) diff --git a/config/index.js b/config/index.js index bfdb3d7..8a410eb 100644 --- a/config/index.js +++ b/config/index.js @@ -43,6 +43,44 @@ module.exports = { cssSourceMap: true }, + demo: { + + // Paths + assetsSubDirectory: 'static', + assetsPublicPath: '/', + proxyTable: {}, + + // Various Dev Server settings + host: '0.0.0.0', // can be overwritten by process.env.HOST + port: 8090, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined + autoOpenBrowser: false, + errorOverlay: true, + notifyOnErrors: true, + poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions- + + // Use Eslint Loader? + // If true, your code will be linted during bundling and + // linting errors and warnings will be shown in the console. + useEslint: true, + // If true, eslint errors and warnings will also be shown in the error overlay + // in the browser. + showEslintErrorsInOverlay: false, + + /** + * Source Maps + */ + + // https://webpack.js.org/configuration/devtool/#development + devtool: 'cheap-module-eval-source-map', + + // If you have problems debugging vue-files in devtools, + // set this to false - it *may* help + // https://vue-loader.vuejs.org/en/options.html#cachebusting + cacheBusting: true, + + cssSourceMap: true + }, + build: { // Template for index.html index: path.resolve(__dirname, '../dist/index.html'),