|
@@ -19,6 +19,8 @@ const merge = require('webpack-merge')
|
|
const { assetsDir, baseConfig } = require('./config')
|
|
const { assetsDir, baseConfig } = require('./config')
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
|
const ProgressPlugin = require('progress-bar-webpack-plugin')
|
|
const ProgressPlugin = require('progress-bar-webpack-plugin')
|
|
|
|
+const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
|
|
|
|
+const portfinder = require('portfinder')
|
|
const getEnv = require('env-parse').getEnv
|
|
const getEnv = require('env-parse').getEnv
|
|
|
|
|
|
const config = merge.smart(baseConfig, {
|
|
const config = merge.smart(baseConfig, {
|
|
@@ -33,6 +35,7 @@ const config = merge.smart(baseConfig, {
|
|
port: getEnv('DEV_PORT', 8888),
|
|
port: getEnv('DEV_PORT', 8888),
|
|
host: getEnv('DEV_HOST', 'localhost'),
|
|
host: getEnv('DEV_HOST', 'localhost'),
|
|
noInfo: false,
|
|
noInfo: false,
|
|
|
|
+ overlay: { warnings: false, errors: true },
|
|
historyApiFallback: true,
|
|
historyApiFallback: true,
|
|
disableHostCheck: true,
|
|
disableHostCheck: true,
|
|
proxy: {
|
|
proxy: {
|
|
@@ -42,12 +45,12 @@ const config = merge.smart(baseConfig, {
|
|
changeOrigin: true
|
|
changeOrigin: true
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- progress: false,
|
|
|
|
- quiet: false,
|
|
|
|
|
|
+ progress: true,
|
|
|
|
+ quiet: true,
|
|
stats: {
|
|
stats: {
|
|
colors: true
|
|
colors: true
|
|
},
|
|
},
|
|
- clientLogLevel: 'none'
|
|
|
|
|
|
+ clientLogLevel: 'warning'
|
|
},
|
|
},
|
|
plugins: [
|
|
plugins: [
|
|
new ProgressPlugin(),
|
|
new ProgressPlugin(),
|
|
@@ -57,4 +60,36 @@ const config = merge.smart(baseConfig, {
|
|
mode: 'development'
|
|
mode: 'development'
|
|
})
|
|
})
|
|
|
|
|
|
-module.exports = config
|
|
|
|
|
|
+module.exports = new Promise((resolve, reject) => {
|
|
|
|
+ portfinder.basePort = process.env.PORT || config.devServer.port
|
|
|
|
+ portfinder.getPort((err, port) => {
|
|
|
|
+ if (err) {
|
|
|
|
+ reject(err)
|
|
|
|
+ } else {
|
|
|
|
+ // publish the new Port, necessary for e2e tests
|
|
|
|
+ process.env.PORT = port
|
|
|
|
+ // add port to devServer config
|
|
|
|
+ config.devServer.port = port
|
|
|
|
+ // Add FriendlyErrorsPlugin
|
|
|
|
+ config.plugins.push(new FriendlyErrorsPlugin({
|
|
|
|
+ compilationSuccessInfo: {
|
|
|
|
+ messages: [`Your application is running here: http://${config.devServer.host}:${port}`],
|
|
|
|
+ },
|
|
|
|
+ onErrors: () => {
|
|
|
|
+ const notifier = require('node-notifier')
|
|
|
|
+ return (severity, errors) => {
|
|
|
|
+ if (severity !== 'error') return
|
|
|
|
+ const error = errors[0]
|
|
|
|
+ const filename = error.file && error.file.split('!').pop()
|
|
|
|
+ notifier.notify({
|
|
|
|
+ title: packageConfig.name,
|
|
|
|
+ message: severity + ': ' + error.name,
|
|
|
|
+ subtitle: filename || ''
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }))
|
|
|
|
+ resolve(config)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+})
|