@plaudit/webpack-extensions 1.1.0 → 1.2.1

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.
@@ -2,6 +2,6 @@ import type { Configuration } from "webpack";
2
2
  export interface PlauditWordpressWebpackConfig {
3
3
  legacyPostcssPlugins?: boolean;
4
4
  variables?: Record<string, any>;
5
- src: Record<string, string>;
5
+ src: string[] | Record<string, string>;
6
6
  }
7
7
  export default function (config: PlauditWordpressWebpackConfig, webpackConfig?: Configuration): Configuration[];
@@ -122,22 +122,23 @@ function default_1(config, webpackConfig = require("@wordpress/scripts/config/we
122
122
  }
123
123
  }
124
124
  }
125
- const copyFiles = !!process.env['WP_COPY_PHP_FILES_TO_DIST'];
126
- const plugins = webpackConfig.plugins ?? [];
127
- plugins.push(new fork_ts_checker_webpack_plugin_1.default({
128
- typescript: {
129
- diagnosticOptions: {
130
- semantic: true,
131
- syntactic: true,
125
+ const sources = Array.isArray(config.src) ? config.src.map(s => [s, s]) : Object.entries(config.src);
126
+ return sources.map(([srcDir, dest]) => {
127
+ const srcRoot = node_path_1.default.join(process.cwd(), srcDir);
128
+ const copyFiles = srcDir !== dest;
129
+ const plugins = webpackConfig.plugins ? [...webpackConfig.plugins] : [];
130
+ plugins.push(new fork_ts_checker_webpack_plugin_1.default({
131
+ typescript: {
132
+ diagnosticOptions: {
133
+ semantic: true,
134
+ syntactic: true,
135
+ }
132
136
  }
137
+ }), new webpack_remove_empty_scripts_1.default({ stage: webpack_remove_empty_scripts_1.default.STAGE_AFTER_PROCESS_PLUGINS, extensions: ['css', 'scss', 'sass', 'less', 'styl', 'pcss'] }));
138
+ if (copyFiles) {
139
+ plugins.push(new BlockJSONStyleRemappingPlugin_1.default());
133
140
  }
134
- }), new webpack_remove_empty_scripts_1.default({ stage: webpack_remove_empty_scripts_1.default.STAGE_AFTER_PROCESS_PLUGINS, extensions: ['css', 'scss', 'sass', 'less', 'styl', 'pcss'] }));
135
- if (copyFiles) {
136
- plugins.push(new BlockJSONStyleRemappingPlugin_1.default());
137
- }
138
- plugins.push(new AdditionalDependencyInjectorPlugin_1.default());
139
- return Object.entries(config.src).map(([srcDir, dest]) => {
140
- const srcRoot = node_path_1.default.join(process.cwd(), srcDir);
141
+ plugins.push(new AdditionalDependencyInjectorPlugin_1.default());
141
142
  return {
142
143
  ...webpackConfig,
143
144
  output: {
@@ -148,7 +149,7 @@ function default_1(config, webpackConfig = require("@wordpress/scripts/config/we
148
149
  ? plugins.map(plugin => plugin.constructor.name === 'CopyPlugin'
149
150
  ? new copy_webpack_plugin_1.default({ patterns: [{ from: '**/(block.json|*.(php|twig|svg))', context: srcRoot, noErrorOnMissing: true }] })
150
151
  : plugin)
151
- : plugins.filter(plugin => plugin.constructor.name !== 'CopyPlugin'),
152
+ : plugins.filter(plugin => plugin.constructor.name !== 'CopyPlugin' && plugin.constructor.name !== 'CleanWebpackPlugin'),
152
153
  entry: node_fs_1.default.readdirSync(srcRoot, 'utf8')
153
154
  .map(dir => node_path_1.default.join(srcRoot, dir))
154
155
  .filter(dir => node_fs_1.default.statSync(dir).isDirectory())
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plaudit/webpack-extensions",
3
- "version": "1.1.0",
3
+ "version": "1.2.1",
4
4
  "scripts": {
5
5
  "prepublishOnly": "rm -rf build && mkdir build && tsc",
6
6
  "build": "tsc",