From e173bbafa5a78c7895a1eab50aeafdf9db9023b9 Mon Sep 17 00:00:00 2001 From: Yurii Pavlov Date: Wed, 20 Dec 2023 21:32:27 +0100 Subject: [PATCH] update prod mode exclude mix.browserSync --- package.json | 6 +++--- webpack.mix.js | 42 ++++++++++++++++++++++-------------------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index 5246d361..e410b41b 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "description": "WordPress starter theme with a modern development stack for launching projects faster and easily", "engines": { "node": ">=18.0.0 <19", - "npm": ">=9 <10" + "npm": ">=9 <11" }, "dependencies": { "@wordpress/babel-preset-default": "7.28.0", @@ -16,8 +16,8 @@ }, "devDependencies": { "@wordpress/eslint-plugin": "17.2.0", - "browser-sync": "2.29.3", - "browser-sync-webpack-plugin": "2.3.0", + "browser-sync": "^2.29.3", + "browser-sync-webpack-plugin": "^2.3.0", "clean-webpack-plugin": "4.0.0", "eslint": "8.52.0", "eslint-webpack-plugin": "4.0.1", diff --git a/webpack.mix.js b/webpack.mix.js index 14f9791b..d79f8dd1 100644 --- a/webpack.mix.js +++ b/webpack.mix.js @@ -125,26 +125,28 @@ allAssets.forEach(assetPath => { /** * BrowserSync runs on dev mode only */ -mix.browserSync({ - /** - * Proxying to nginx container with alias APP_DOMAIN - * Proxy should be the same as WP_SITEURL in wp-config.php - */ - proxy: getAppUrl(), - /** - * Set external host network IP. - * If hostIp is undefined, just find your local network IP in your system - * and use it in your other devices browser to sync with BrowserSync. - */ - host: getHostIp(), - port: 3000, - open: false, - files: [ - '**/*.php', - '**/*.twig', - '**/src/**/*.@(scss|js|jsx)', - ], -}); +if (!mix.inProduction()) { + mix.browserSync({ + /** + * Proxying to nginx container with alias APP_DOMAIN + * Proxy should be the same as WP_SITEURL in wp-config.php + */ + proxy: getAppUrl(), + /** + * Set external host network IP. + * If hostIp is undefined, just find your local network IP in your system + * and use it in your other devices browser to sync with BrowserSync. + */ + host: getHostIp(), + port: 3000, + open: false, + files: [ + '**/*.php', + '**/*.twig', + '**/src/**/*.@(scss|js|jsx)', + ], + }); +} function getAppUrl() { const appProtocol = process.env.APP_PROTOCOL;