Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove browser-sync #329

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/gold-scissors-shake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"10up-toolkit": major
---

Remove browser-sync support
Original file line number Diff line number Diff line change
Expand Up @@ -1596,7 +1596,6 @@ Object {
ESLintWebpackPlugin: {"extensions":"js","emitError":true,"emitWarning":true,"failOnError":false,"resourceQueryExclude":[],"fix":false,"lintDirtyModulesOnly":true},
MiniCssExtractPlugin: {"ignoreOrder":false,"runtime":true,"chunkFilename":"[id].css"},
CopyPlugin: {},
NoBrowserSyncPlugin: {},
StylelintWebpackPlugin: {"cache":true,"cacheLocation":"node_modules/.cache/stylelint-webpack-plugin/.stylelintcache","extensions":["css","scss","sass"],"emitError":true,"emitWarning":true,"failOnError":false,"context":"/assets2","files":"**/*.(s(c|a)ss|css)","allowEmptyInput":true,"lintDirtyModulesOnly":true,"configFile":"/config/stylelint.config.js"},
WebpackBarPlugin: {"name":"webpack","color":"green","reporters":["basic"],"reporter":null},
DependencyExtractionWebpackPlugin: {"combineAssets":false,"combinedOutputFile":null,"externalizedReport":false,"injectPolyfill":false,"outputFormat":"php","outputFilename":null,"useDefaults":true},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,6 @@ Object {
ESLintWebpackPlugin: {"extensions":"js","emitError":true,"emitWarning":true,"failOnError":false,"resourceQueryExclude":[],"fix":false,"lintDirtyModulesOnly":true},
MiniCssExtractPlugin: {"ignoreOrder":false,"runtime":true,"chunkFilename":"[id].css"},
CopyPlugin: {},
NoBrowserSyncPlugin: {},
StylelintWebpackPlugin: {"cache":true,"cacheLocation":"node_modules/.cache/stylelint-webpack-plugin/.stylelintcache","extensions":["css","scss","sass"],"emitError":true,"emitWarning":true,"failOnError":false,"context":"/assets","files":"**/*.(s(c|a)ss|css)","allowEmptyInput":true,"lintDirtyModulesOnly":true},
WebpackBarPlugin: {"name":"webpack","color":"green","reporters":["basic"],"reporter":null},
DependencyExtractionWebpackPlugin: {"combineAssets":false,"combinedOutputFile":null,"externalizedReport":false,"injectPolyfill":false,"outputFormat":"php","outputFilename":null,"useDefaults":true},
Expand Down
37 changes: 0 additions & 37 deletions packages/toolkit/config/webpack/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,13 @@ const { resolve } = require('path');
const RemoveEmptyScriptsPlugin = require('./plugins/remove-empty-scripts');
const CleanExtractedDeps = require('./plugins/clean-extracted-deps');
const TenUpToolkitTscPlugin = require('./plugins/tsc');
const NoBrowserSyncPlugin = require('./plugins/no-browser-sync');

const {
hasStylelintConfig,
fromConfigRoot,
hasProjectFile,
getArgFromCLI,
maybeInsertStyleVersionHash,
} = require('../../utils');
const { isPackageInstalled } = require('../../utils/package');

const removeDistFolder = (file) => {
return file.replace(/(^\.\/dist\/)|^dist\//, '');
Expand All @@ -38,7 +35,6 @@ module.exports = ({
projectConfig: {
devServer,
filenames,
devURL,
devServerPort,
paths,
wpDependencyExternals,
Expand All @@ -51,38 +47,6 @@ module.exports = ({
}) => {
const hasReactFastRefresh = hot && !isProduction;

const hasBrowserSync =
isPackageInstalled('browser-sync-webpack-plugin') && isPackageInstalled('browser-sync');

const shouldLoadBrowserSync = !isProduction && devURL && !hasReactFastRefresh && hasBrowserSync;

let browserSync = !isProduction && devURL ? new NoBrowserSyncPlugin() : false;
if (shouldLoadBrowserSync) {
// eslint-disable-next-line global-require, import/no-extraneous-dependencies
const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
browserSync = new BrowserSyncPlugin(
{
host: 'localhost',
port: getArgFromCLI('--port') || 3000,
proxy: devURL,
open: false,
files: ['**/*.php', '**/*.js', 'dist/**/*.css'],
ignore: ['dist/**/*.php', 'dist/**/*.js'],
serveStatic: ['.'],
rewriteRules: [
{
match: /wp-content\/themes\/.*\/dist/g,
replace: 'dist',
},
],
},
{
injectCss: true,
reload: false,
},
);
}

const blocksSourceDirectory = resolve(process.cwd(), paths.blocksDir);

return [
Expand Down Expand Up @@ -180,7 +144,6 @@ module.exports = ({
},
].filter(Boolean),
}),
devURL && browserSync,
// Lint CSS.
new StyleLintPlugin({
context: path.resolve(process.cwd(), paths.srcDir),
Expand Down
27 changes: 0 additions & 27 deletions packages/toolkit/config/webpack/plugins/no-browser-sync.js

This file was deleted.

Loading