Skip to content

Commit

Permalink
新增demo dev配置
Browse files Browse the repository at this point in the history
  • Loading branch information
wangweicong committed Sep 11, 2019
1 parent 0dab275 commit d36fc79
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 13 deletions.
26 changes: 13 additions & 13 deletions build/webpack.dev.demo.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand All @@ -64,15 +64,15 @@ const devWebpackConfig = merge(baseWebpackConfig, {
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, '../static'),
to: config.dev.assetsSubDirectory,
to: config.demo.assetsSubDirectory,
ignore: ['.*']
}
])
]
})

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)
Expand All @@ -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
}))
Expand Down
38 changes: 38 additions & 0 deletions config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down

0 comments on commit d36fc79

Please sign in to comment.