@plaudit/webpack-extensions 2.58.4 → 2.60.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,8 +9,7 @@ export type PluginOptions = {
9
9
  };
10
10
  export declare class BrowserSyncPlugin implements WebpackPluginInstance {
11
11
  private static isBrowserSyncRunning;
12
- private static browserSyncPluginOptions;
13
- private static envFileContents;
12
+ private static browserSyncPluginOptions?;
14
13
  private readonly pluginOptions;
15
14
  private readonly browserSyncInstance;
16
15
  private isWebpackWatching;
@@ -18,7 +17,8 @@ export declare class BrowserSyncPlugin implements WebpackPluginInstance {
18
17
  private shouldNotify;
19
18
  constructor(pluginOptions?: Partial<PluginOptions>);
20
19
  private static getBrowserSyncPluginOptions;
21
- private static loadEnvFile;
20
+ private static findEnvFile;
22
21
  apply(compiler: Compiler): void;
23
22
  private getCssOnlyEmittedAssetsNames;
23
+ private static getSiteUrls;
24
24
  }
@@ -7,13 +7,13 @@ exports.BrowserSyncPlugin = void 0;
7
7
  const node_child_process_1 = __importDefault(require("node:child_process"));
8
8
  const node_fs_1 = __importDefault(require("node:fs"));
9
9
  const node_path_1 = __importDefault(require("node:path"));
10
+ const shared_1 = require("../shared");
10
11
  const browser_sync_1 = __importDefault(require("browser-sync"));
11
12
  const http_proxy_middleware_1 = require("http-proxy-middleware");
12
13
  const open_1 = __importDefault(require("open"));
13
14
  class BrowserSyncPlugin {
14
15
  static isBrowserSyncRunning = false;
15
- static browserSyncPluginOptions = undefined;
16
- static envFileContents = undefined;
16
+ static browserSyncPluginOptions;
17
17
  pluginOptions;
18
18
  browserSyncInstance;
19
19
  isWebpackWatching = false;
@@ -24,13 +24,11 @@ class BrowserSyncPlugin {
24
24
  this.browserSyncInstance = browser_sync_1.default.has(this.pluginOptions.name) ? browser_sync_1.default.get(this.pluginOptions.name) : browser_sync_1.default.create(this.pluginOptions.name);
25
25
  }
26
26
  static getBrowserSyncPluginOptions() {
27
- return BrowserSyncPlugin.browserSyncPluginOptions ?? (BrowserSyncPlugin.browserSyncPluginOptions = new Promise(resolve => {
28
- const envFile = BrowserSyncPlugin.loadEnvFile();
29
- const prefixes = node_child_process_1.default.spawnSync("theapp", ["info", "--for-browsersync"], {
30
- encoding: "utf-8",
31
- stdio: ["ignore", "pipe", "inherit"]
32
- }).stdout.split(/\r?\n/g).map(url => url.trim()).filter(url => url.length > 0).map(url => url.substring(url.indexOf("://") + 3));
33
- const targetPort = envFile.match(/WEB_PORT_SSL=(\d+)/i)?.[1] ?? "8443";
27
+ return BrowserSyncPlugin.browserSyncPluginOptions ?? (BrowserSyncPlugin.browserSyncPluginOptions = new Promise(async (resolve) => {
28
+ const envFilePath = BrowserSyncPlugin.findEnvFile();
29
+ const envFile = envFilePath ? await (0, shared_1.loadEnvFile)(envFilePath) : {};
30
+ const prefixes = BrowserSyncPlugin.getSiteUrls();
31
+ const targetPort = envFile["WEB_PORT_SSL"]?.match(/^\d+$/) ? envFile["WEB_PORT_SSL"] : "8443";
34
32
  const targetHost = targetPort === "443" ? "localhost" : `localhost:${targetPort}`;
35
33
  if (prefixes.length === 0 || prefixes.every(prefix => prefix.startsWith("localhost"))) {
36
34
  resolve([{
@@ -49,7 +47,7 @@ class BrowserSyncPlugin {
49
47
  callbacks: {
50
48
  ready(err, bsi) {
51
49
  // This ensures that the opened URL is actually a valid one
52
- (0, open_1.default)(`https://${prefixes[0]}:${bsi.getOption("port") ?? 3000}`);
50
+ (0, open_1.default)(`https://${prefixes[0]?.replace(/:\d{2,4}/, "")}:${bsi.getOption("port") ?? 3000}`);
53
51
  }
54
52
  }
55
53
  }, {
@@ -90,18 +88,28 @@ class BrowserSyncPlugin {
90
88
  }
91
89
  }));
92
90
  }
93
- static loadEnvFile() {
94
- if (BrowserSyncPlugin.envFileContents !== undefined) {
95
- return BrowserSyncPlugin.envFileContents;
96
- }
91
+ static findEnvFile() {
97
92
  for (let envFileHolderPath = process.cwd(); envFileHolderPath.length > 5; envFileHolderPath = node_path_1.default.dirname(envFileHolderPath)) {
98
93
  if (node_fs_1.default.existsSync(node_path_1.default.join(envFileHolderPath, ".env"))) {
99
- return BrowserSyncPlugin.envFileContents = node_fs_1.default.readFileSync(node_path_1.default.join(envFileHolderPath, ".env"), { encoding: 'utf8' });
94
+ return node_path_1.default.join(envFileHolderPath, ".env");
100
95
  }
101
96
  }
102
- return "";
97
+ return undefined;
103
98
  }
104
99
  apply(compiler) {
100
+ if (!process.argv.includes('--browser-sync') && process.env['BROWSER_SYNC'] !== 'true') {
101
+ return;
102
+ }
103
+ let devTarget = process.env['DEV_TARGET'] ?? process.argv.find(a => a.startsWith("--dev-target="))?.substring(13);
104
+ if (devTarget === undefined) {
105
+ const flagIndex = process.argv.findIndex(a => a === "--dev-target");
106
+ if (flagIndex > -1) {
107
+ devTarget = process.argv[flagIndex + 1];
108
+ }
109
+ }
110
+ if (devTarget !== undefined && devTarget !== node_path_1.default.basename(process.cwd()) && !(devTarget === "theme" && node_fs_1.default.existsSync(node_path_1.default.join(process.cwd(), "style.css")))) {
111
+ return;
112
+ }
105
113
  compiler.hooks.watchRun.tap(BrowserSyncPlugin.name, () => {
106
114
  this.isWebpackWatching = true;
107
115
  });
@@ -173,5 +181,33 @@ class BrowserSyncPlugin {
173
181
  }
174
182
  return changedFilenames;
175
183
  }
184
+ static getSiteUrls() {
185
+ //docker container inspect "$(docker compose ps --format=json | jq '. | select(. | contains({"Service": "wordpress"})) | .ID' -r)" | jq '.[].Config.Env'
186
+ const serviceId = node_child_process_1.default.spawnSync("docker", ["compose", "ps", "--format=json"], { encoding: "utf-8", stdio: ["ignore", "pipe", "inherit"] })
187
+ .stdout.trim().split("\n").map(item => JSON.parse(item.trim())).find(item => item.Service === "wordpress")?.ID;
188
+ if (serviceId === undefined) {
189
+ return ["localhost"]; // This will only happen for Tomcat or misconfigured containers, both of which should use localhost
190
+ }
191
+ const inspectionResult = node_child_process_1.default.spawnSync("docker", ["container", "inspect", "--format=json", serviceId], { encoding: "utf-8", stdio: ["ignore", "pipe", "inherit"] })
192
+ .stdout.trim();
193
+ const containerEnv = Object.fromEntries(JSON.parse(inspectionResult)[0]?.Config.Env.map((envEntry) => {
194
+ const equalSignIndex = envEntry.indexOf('=');
195
+ return [envEntry.substring(0, equalSignIndex), envEntry.substring(equalSignIndex + 1)];
196
+ }));
197
+ if (containerEnv['WORDPRESS_MAPPED_DOMAINS'] !== '1') {
198
+ return ["localhost:8443"]; //This will only happen for legacy WordPress sites
199
+ }
200
+ let siteUrls;
201
+ const multisiteUrlsProcess = node_child_process_1.default.spawnSync("docker", ["compose", "exec", "--user=www-data", "wordpress", "wp", "site", "list", "--field=url", "--quiet"], { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] }); // We're forced to mute stderr here because it is otherwise almost guaranteed to print
202
+ if (!multisiteUrlsProcess.error && !multisiteUrlsProcess.status && !multisiteUrlsProcess.signal) {
203
+ siteUrls = multisiteUrlsProcess.stdout.split("\n").map(line => line.trim()).filter(line => line.length > 0);
204
+ }
205
+ else {
206
+ siteUrls = [node_child_process_1.default.spawnSync("docker", ["compose", "exec", "--user=www-data", "wordpress", "wp", "option", "get", "siteurl"], { encoding: "utf-8", stdio: ["ignore", "pipe", "inherit"] }).stdout.trim()];
207
+ }
208
+ // Because mapped domain sites that are using my mapping scheme hyphenate instances of "www.", this is an effective test for whether it is in use.
209
+ // If the URL still has the "www.", then it is using David's mapping scheme and should be accessed via localhost
210
+ return siteUrls.map(siteUrl => siteUrl.includes("www.") ? "localhost" : siteUrl).map(siteUrl => siteUrl.replace(/^https?:\/\//i, ""));
211
+ }
176
212
  }
177
213
  exports.BrowserSyncPlugin = BrowserSyncPlugin;
@@ -1,12 +1,12 @@
1
+ import type { VerifiedPlauditWordpressWebpackConfig } from "../utils/common-config-helpers";
1
2
  import { type Compiler, type WebpackPluginInstance } from "webpack";
2
3
  export declare class SpecialAssetHandlingPlugin implements WebpackPluginInstance {
3
- private readonly outputDir;
4
- private readonly useUnifiedLoader;
4
+ private readonly config;
5
5
  private static readonly semaphore;
6
6
  private static hasAttachedAssetCollatorForCurrentBatch;
7
7
  private static validPathname?;
8
8
  private readonly id;
9
- constructor(outputDir: string, useUnifiedLoader: boolean);
9
+ constructor(config: VerifiedPlauditWordpressWebpackConfig);
10
10
  apply(compiler: Compiler): void;
11
11
  private collateAssets;
12
12
  }
@@ -5,26 +5,27 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.SpecialAssetHandlingPlugin = void 0;
7
7
  const node_path_1 = __importDefault(require("node:path"));
8
- const PlainEntrypointsConfigFileGeneratorPlugin_1 = require("./PlainEntrypointsConfigFileGeneratorPlugin");
9
8
  const php_writer_1 = require("../utils/php-writer");
10
9
  const pseduo_semaphore_1 = require("../utils/pseduo-semaphore");
11
- const webpack_1 = require("webpack");
10
+ const PlainEntrypointsConfigFileGeneratorPlugin_1 = require("./PlainEntrypointsConfigFileGeneratorPlugin");
12
11
  const UnifiedLoaderGenerator_1 = require("./UnifiedLoaderGenerator");
12
+ const webpack_1 = require("webpack");
13
13
  class SpecialAssetHandlingPlugin {
14
- outputDir;
15
- useUnifiedLoader;
14
+ config;
16
15
  static semaphore = new pseduo_semaphore_1.PseudoSemaphore({}, "Special");
17
16
  static hasAttachedAssetCollatorForCurrentBatch = false;
18
17
  static validPathname = undefined;
19
18
  id;
20
- constructor(outputDir, useUnifiedLoader) {
21
- this.outputDir = outputDir;
22
- this.useUnifiedLoader = useUnifiedLoader;
19
+ constructor(config) {
20
+ this.config = config;
23
21
  this.id = Math.random().toString();
24
- SpecialAssetHandlingPlugin.semaphore.register(this.id);
25
- UnifiedLoaderGenerator_1.UnifiedLoaderGenerator.semaphore.register(this.id);
26
22
  }
27
23
  apply(compiler) {
24
+ if (!this.config.useWebpackResourceFiltering) {
25
+ return;
26
+ }
27
+ SpecialAssetHandlingPlugin.semaphore.register(this.id);
28
+ UnifiedLoaderGenerator_1.UnifiedLoaderGenerator.semaphore.register(this.id);
28
29
  compiler.hooks.compilation.tap(this.constructor.name, compilation => {
29
30
  SpecialAssetHandlingPlugin.hasAttachedAssetCollatorForCurrentBatch = false;
30
31
  SpecialAssetHandlingPlugin.semaphore.reset(this.id);
@@ -81,15 +82,15 @@ class SpecialAssetHandlingPlugin {
81
82
  const preloadedAssets = Object.entries(collatedSpecialAssetData)
82
83
  .filter(([_, { preload }]) => preload)
83
84
  .sort(([a], [b]) => a.localeCompare(b));
84
- const outputFile = this.outputDir ? "special-assets.php" : node_path_1.default.join(node_path_1.default.dirname(node_path_1.default.dirname(SpecialAssetHandlingPlugin.validPathname)), "special-assets.php");
85
+ const outputFile = this.config.outputDir ? "special-assets.php" : node_path_1.default.join(node_path_1.default.dirname(node_path_1.default.dirname(SpecialAssetHandlingPlugin.validPathname)), "special-assets.php");
85
86
  const writer = new php_writer_1.PHPWriter();
86
87
  if (!preloadedAssets.length) {
87
- if (!this.useUnifiedLoader) {
88
+ if (!this.config.useUnifiedLoader) {
88
89
  writer.emitAsset(compilation, outputFile);
89
90
  }
90
91
  return;
91
92
  }
92
- if (!this.useUnifiedLoader) {
93
+ if (!this.config.useUnifiedLoader) {
93
94
  PlainEntrypointsConfigFileGeneratorPlugin_1.PlainEntrypointsConfigFileGeneratorPlugin.emitResolveBaseUriFunction(writer);
94
95
  }
95
96
  writer.action("wp_head", writer => {
@@ -1,3 +1,4 @@
1
+ import type { VerifiedPlauditWordpressWebpackConfig } from "../utils/common-config-helpers";
1
2
  import { PseudoSemaphore } from "../utils/pseduo-semaphore";
2
3
  import { PHPWriter } from "../utils/php-writer";
3
4
  import { Compiler, WebpackPluginInstance } from "webpack";
@@ -8,10 +9,11 @@ type LoaderInfo = {
8
9
  priority?: number;
9
10
  };
10
11
  export declare class UnifiedLoaderGenerator implements WebpackPluginInstance {
12
+ private readonly config;
11
13
  static readonly semaphore: PseudoSemaphore<LoaderInfo | undefined>;
12
14
  private static attached;
13
15
  private readonly id;
14
- constructor();
16
+ constructor(config: VerifiedPlauditWordpressWebpackConfig);
15
17
  apply(compiler: Compiler): void;
16
18
  }
17
19
  export {};
@@ -3,17 +3,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UnifiedLoaderGenerator = void 0;
4
4
  const pseduo_semaphore_1 = require("../utils/pseduo-semaphore");
5
5
  const php_writer_1 = require("../utils/php-writer");
6
- const webpack_1 = require("webpack");
7
6
  const PlainEntrypointsConfigFileGeneratorPlugin_1 = require("./PlainEntrypointsConfigFileGeneratorPlugin");
7
+ const webpack_1 = require("webpack");
8
8
  class UnifiedLoaderGenerator {
9
+ config;
9
10
  static semaphore = new pseduo_semaphore_1.PseudoSemaphore(undefined, "Unified");
10
11
  static attached = false;
11
12
  id;
12
- constructor() {
13
+ constructor(config) {
14
+ this.config = config;
13
15
  this.id = Math.random().toString();
14
- UnifiedLoaderGenerator.semaphore.register(this.id);
15
16
  }
16
17
  apply(compiler) {
18
+ if (!this.config.useUnifiedLoader) {
19
+ return;
20
+ }
21
+ UnifiedLoaderGenerator.semaphore.register(this.id);
17
22
  const tapName = { name: this.constructor.name, stage: webpack_1.Compilation.PROCESS_ASSETS_STAGE_REPORT };
18
23
  compiler.hooks.compilation.tap(this.constructor.name, compilation => {
19
24
  UnifiedLoaderGenerator.attached = false;
@@ -1,6 +1,7 @@
1
+ import type { VerifiedPlauditWordpressWebpackConfig } from "../utils/common-config-helpers";
1
2
  import type { Compiler, WebpackPluginInstance } from "webpack";
2
3
  export declare class VariablesJSMonitorPlugin implements WebpackPluginInstance {
3
- private readonly variablesFilePath;
4
- constructor(variablesFilePath: string);
4
+ private readonly config;
5
+ constructor(config: VerifiedPlauditWordpressWebpackConfig);
5
6
  apply(compiler: Compiler): void;
6
7
  }
@@ -2,16 +2,19 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VariablesJSMonitorPlugin = void 0;
4
4
  class VariablesJSMonitorPlugin {
5
- variablesFilePath;
6
- constructor(variablesFilePath) {
7
- this.variablesFilePath = variablesFilePath;
5
+ config;
6
+ constructor(config) {
7
+ this.config = config;
8
8
  }
9
9
  apply(compiler) {
10
- compiler.hooks.make.tap(this.constructor.name, compilation => {
11
- if (!compilation.fileDependencies.has(this.variablesFilePath)) {
12
- compilation.fileDependencies.add(this.variablesFilePath);
13
- }
14
- });
10
+ const variablesFilePath = this.config.variablesFilePath;
11
+ if (variablesFilePath) {
12
+ compiler.hooks.make.tap(this.constructor.name, compilation => {
13
+ if (!compilation.fileDependencies.has(variablesFilePath)) {
14
+ compilation.fileDependencies.add(variablesFilePath);
15
+ }
16
+ });
17
+ }
15
18
  }
16
19
  }
17
20
  exports.VariablesJSMonitorPlugin = VariablesJSMonitorPlugin;
package/build/shared.d.ts CHANGED
@@ -95,4 +95,6 @@ export declare const styleExtension: RegExp;
95
95
  export declare function scriptOrStyleTest(entryPath: string, scriptExtension: RegExp): "" | "script" | "style";
96
96
  export declare function hasAtLeastOneItem<T>(list: T[]): list is [T, ...T[]];
97
97
  export declare function kebabCase(value: string): string;
98
+ export declare function loadEnvFile(filePath: string): Promise<Record<string, string>>;
99
+ export declare function parseEnvFile(contents: string): Record<string, string>;
98
100
  export {};
package/build/shared.js CHANGED
@@ -11,7 +11,10 @@ exports.leadingSlashIt = leadingSlashIt;
11
11
  exports.scriptOrStyleTest = scriptOrStyleTest;
12
12
  exports.hasAtLeastOneItem = hasAtLeastOneItem;
13
13
  exports.kebabCase = kebabCase;
14
+ exports.loadEnvFile = loadEnvFile;
15
+ exports.parseEnvFile = parseEnvFile;
14
16
  const json_to_php_but_with____injection_1 = __importDefault(require("./utils/json-to-php-but-with-__-injection"));
17
+ const promises_1 = __importDefault(require("node:fs/promises"));
15
18
  function isRawAssetData(thing) {
16
19
  if (!thing || typeof thing !== 'object') {
17
20
  return false;
@@ -87,3 +90,14 @@ function kebabCase(value) {
87
90
  const kebabCaseRegexes = [[/([a-z])([A-Z])/g, "$1-$2"], [/[\s_.\-]+/g, "-"]];
88
91
  return kebabCaseRegexes.reduce((str, [pattern, replacement]) => str.replace(pattern, replacement), value).toLowerCase();
89
92
  }
93
+ async function loadEnvFile(filePath) {
94
+ return promises_1.default.readFile(filePath, 'utf-8').then(parseEnvFile, () => ({}));
95
+ }
96
+ function parseEnvFile(contents) {
97
+ return Object.fromEntries(contents.split(/(\r?\n)+/).map(line => line.trim())
98
+ .filter(line => line.length > 0 && !line.startsWith("#") && !line.startsWith("//"))
99
+ .map(line => {
100
+ const equalsPos = line.indexOf('=');
101
+ return equalsPos === -1 ? [line, ""] : [line.substring(0, equalsPos), line.substring(equalsPos + 1)];
102
+ }));
103
+ }
@@ -8,11 +8,11 @@ exports.groupEntrypointsByAssetFile = groupEntrypointsByAssetFile;
8
8
  exports.resolveEntryFromDirectory = resolveEntryFromDirectory;
9
9
  exports.commonMakeWebpackConfig = commonMakeWebpackConfig;
10
10
  const node_fs_1 = __importDefault(require("node:fs"));
11
+ const promises_1 = __importDefault(require("node:fs/promises"));
11
12
  const node_path_1 = __importDefault(require("node:path"));
13
+ const BlockJSONManagingPlugin_1 = require("../plugins/BlockJSONManagingPlugin");
12
14
  const shared_1 = require("../shared");
13
15
  const copy_webpack_plugin_1 = __importDefault(require("copy-webpack-plugin"));
14
- const promises_1 = __importDefault(require("node:fs/promises"));
15
- const BlockJSONManagingPlugin_1 = require("../plugins/BlockJSONManagingPlugin");
16
16
  let isInThemeCache = undefined;
17
17
  function isInTheme() {
18
18
  return isInThemeCache ?? (isInThemeCache = node_fs_1.default.existsSync(node_path_1.default.join(process.cwd(), "theme.json")));
@@ -256,7 +256,8 @@ function commonMakeWebpackConfig(config, commonConfig, webpackConfig, srcIsDirec
256
256
  }
257
257
  const canCopyFiles = srcIsDirectory && src !== dest.destination;
258
258
  const possiblePlugins = canCopyFiles
259
- ? plugins.map(plugin => !processingModules && plugin.constructor.name === 'CopyPlugin'
259
+ ? plugins.filter(plugin => plugin.constructor.name !== 'CleanWebpackPlugin')
260
+ .map(plugin => !processingModules && plugin.constructor.name === 'CopyPlugin'
260
261
  ? new copy_webpack_plugin_1.default({
261
262
  patterns: [{
262
263
  from: standaloneBlocks ? '**/(block.json|*.(php|twig|svg))' : '**/(block.json|*.(asset\.php|svg))',
@@ -265,9 +266,7 @@ function commonMakeWebpackConfig(config, commonConfig, webpackConfig, srcIsDirec
265
266
  }]
266
267
  })
267
268
  : plugin)
268
- : (srcIsDirectory
269
- ? plugins.filter(plugin => plugin.constructor.name !== 'CopyPlugin' && plugin.constructor.name !== 'CleanWebpackPlugin')
270
- : plugins.filter(plugin => plugin.constructor.name !== 'CopyPlugin'));
269
+ : plugins.filter(plugin => plugin.constructor.name !== 'CopyPlugin' && plugin.constructor.name !== 'CleanWebpackPlugin');
271
270
  const extensions = processingModules ? ['.mjsx', '.mjs', '.mtsx', '.mts', '...'] : ['.jsx', '.tsx', '.ts', '...'];
272
271
  return {
273
272
  ...webpackConfig,
@@ -312,7 +311,7 @@ function commonMakeWebpackConfig(config, commonConfig, webpackConfig, srcIsDirec
312
311
  extensions
313
312
  },
314
313
  stats: config.stats,
315
- plugins: config.outputDir ? possiblePlugins : possiblePlugins.filter(plugin => plugin.constructor.name !== 'CleanWebpackPlugin'),
314
+ plugins: possiblePlugins,
316
315
  entry() {
317
316
  if (variablesFilePath) {
318
317
  delete require.cache[require.resolve(variablesFilePath)];
@@ -354,7 +354,7 @@ function handleDisablingTSCheckerIfNecessary(srcRoot, scriptExtension, plugins)
354
354
  }
355
355
  }
356
356
  function buildCommonPluginConfig(srcRoot, scriptExtension, webpackConfig, dest, config, sourceType) {
357
- const { assumeGlobalizedPlauditLibraries, combineAssetMetadata, externals, extensionsVersion, plainEntrypointsVersion, variablesFilePath } = config;
357
+ const { assumeGlobalizedPlauditLibraries, combineAssetMetadata, externals, extensionsVersion, plainEntrypointsVersion, } = config;
358
358
  const processingModules = webpackConfig.output?.module ?? false;
359
359
  const plugins = webpackConfig.plugins?.filter(v => !!v)
360
360
  .filter(plugin => plugin.constructor.name !== 'RtlCssPlugin')
@@ -380,15 +380,9 @@ function buildCommonPluginConfig(srcRoot, scriptExtension, webpackConfig, dest,
380
380
  extensions: ['css', 'scss', 'sass', 'less', 'styl', 'pcss']
381
381
  });
382
382
  plugins.push(removeEmptyScriptsPlugin, new MiniCSSExtractPluginErrorCleaner_1.MiniCSSExtractPluginErrorCleaner());
383
- if (config.useUnifiedLoader) {
384
- plugins.push(new UnifiedLoaderGenerator_1.UnifiedLoaderGenerator());
385
- }
386
- if (config.useWebpackResourceFiltering) {
387
- plugins.push(new SpecialAssetHandlingPlugin_1.SpecialAssetHandlingPlugin(config.outputDir, config.useUnifiedLoader));
388
- }
389
- if (variablesFilePath) {
390
- plugins.push(new VariablesJSMonitorPlugin_1.VariablesJSMonitorPlugin(variablesFilePath));
391
- }
383
+ plugins.push(new UnifiedLoaderGenerator_1.UnifiedLoaderGenerator(config));
384
+ plugins.push(new SpecialAssetHandlingPlugin_1.SpecialAssetHandlingPlugin(config));
385
+ plugins.push(new VariablesJSMonitorPlugin_1.VariablesJSMonitorPlugin(config));
392
386
  const dependencyExtractionPluginIndex = plugins.findIndex(plugin => plugin instanceof dependency_extraction_webpack_plugin_1.default);
393
387
  if (dependencyExtractionPluginIndex === -1) {
394
388
  console.error("Cannot apply externals when they have been disabled via CLI flag. This will greatly increase bundle size and will likely cause the build to fail");
@@ -403,9 +397,7 @@ function buildCommonPluginConfig(srcRoot, scriptExtension, webpackConfig, dest,
403
397
  plugins[dependencyExtractionPluginIndex] = builtDependencyExtractionWebpackPlugin.instance;
404
398
  plugins.push(new AdditionalDependencyInjectorPlugin_1.AdditionalDependencyInjectorPlugin(dest.additionalDependencies ? dest.additionalDependencies : [], processingModules, builtDependencyExtractionWebpackPlugin.addExternalizedDep));
405
399
  }
406
- if (process.argv.includes('--browser-sync') || process.env['BROWSER_SYNC'] === 'true') {
407
- plugins.push(new BrowserSyncPlugin_1.BrowserSyncPlugin());
408
- }
400
+ plugins.push(new BrowserSyncPlugin_1.BrowserSyncPlugin());
409
401
  return { plugins, removeEmptyScriptsPlugin };
410
402
  }
411
403
  function commonConfigProcessingPrep(config, webpackConfig) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plaudit/webpack-extensions",
3
- "version": "2.58.4",
3
+ "version": "2.60.0",
4
4
  "license": "UNLICENSED",
5
5
  "files": [
6
6
  "/build"