Skip to content

Commit 99a5ba3

Browse files
committed
refactor (webpack) : getServerPort method
1 parent aa4eb08 commit 99a5ba3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

webpack.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin')
99
const SoundsPlugin = require('sounds-webpack-plugin')
1010
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
1111
const WebpackProgressOraPlugin = require('webpack-progress-ora-plugin')
12-
const getServerPort = function(portFile, defaultPort) {
12+
const getServerPort = function(portFile) {
1313
try {
1414
require('fs').accessSync(portFile, fs.R_OK | fs.W_OK)
1515

1616
return parseInt(fs.readFileSync(portFile, 'utf8'))
1717
} catch (e) {
18-
return defaultPort
18+
return false
1919
}
2020
}
2121
const webpackConfig = {
@@ -177,8 +177,8 @@ module.exports = (env, argv) => {
177177
}),
178178
new BrowserSyncPlugin(
179179
{
180-
port: getServerPort('./.bs-port', 3000),
181-
proxy: 'http://[::1]:' + getServerPort('./.port', 9090),
180+
port: getServerPort('./.bs-port') || 3000,
181+
proxy: 'http://[::1]:' + (getServerPort('./.port') || 9090),
182182
files: [
183183
{
184184
match: config.refresh,

0 commit comments

Comments
 (0)