File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change 1+ const fs = require ( 'fs' )
12const config = require ( './webpack.settings' )
23const BrowserSyncPlugin = require ( 'browser-sync-webpack-plugin' )
34const BundleAnalyzerPlugin = require ( 'webpack-bundle-analyzer' ) . BundleAnalyzerPlugin
@@ -8,7 +9,15 @@ const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin')
89const SoundsPlugin = require ( 'sounds-webpack-plugin' )
910const UglifyJsPlugin = require ( 'uglifyjs-webpack-plugin' )
1011const WebpackProgressOraPlugin = require ( 'webpack-progress-ora-plugin' )
12+ const getServerPort = function ( portFile , defaultPort ) {
13+ try {
14+ require ( 'fs' ) . accessSync ( portFile , fs . R_OK | fs . W_OK )
1115
16+ return parseInt ( fs . readFileSync ( portFile , 'utf8' ) )
17+ } catch ( e ) {
18+ return defaultPort
19+ }
20+ }
1221const webpackConfig = {
1322 entry : config . entry ,
1423 output : {
@@ -168,7 +177,8 @@ module.exports = (env, argv) => {
168177 } ) ,
169178 new BrowserSyncPlugin (
170179 {
171- proxy : 'http://[::1]:' + config . port ,
180+ port : getServerPort ( './.bs-port' , 3000 ) ,
181+ proxy : 'http://[::1]:' + getServerPort ( './.port' , 9090 ) ,
172182 files : [
173183 {
174184 match : config . refresh ,
Original file line number Diff line number Diff line change @@ -6,7 +6,6 @@ module.exports = {
66 'editor-style' : './src/scss/editor-style.scss' ,
77 } ,
88 assetsPath : path . resolve ( __dirname , 'dist/assets' ) ,
9- port : 9090 ,
109 dev : process . env . NODE_ENV === 'dev' ,
1110 refresh : [
1211 'dist/**/*.php' ,
You can’t perform that action at this time.
0 commit comments