@sumotto/configs 0.0.21 → 0.0.22

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sumotto/configs",
3
- "version": "0.0.21",
3
+ "version": "0.0.22",
4
4
  "description": "Configs for my work",
5
5
  "scripts": {
6
6
  "release": "np --yolo"
@@ -21,7 +21,7 @@ const port =
21
21
 
22
22
  const defaultConfig = new Config( defaultConfigWP, 'default', port )
23
23
  .addEntries( 'src/blocks/**/styles/*.{pc,sc,sa,c}ss' )
24
- .addEntries( 'src/index.{ts,tsx}' )
24
+ .addEntries( 'src/*.{ts,tsx}' )
25
25
  .removePlugin( RtlCssPlugin )
26
26
  .replacePlugin(
27
27
  new MiniCSSExtractPlugin( {
@@ -63,7 +63,7 @@ if ( process.env.WP_CONTENT_DIR ) {
63
63
  const syncDirectory = new SyncDirectoryWebpackPlugin( {
64
64
  sourceDir: rootPath,
65
65
  targetDir: outputPath,
66
- exclude: [ /build/ ],
66
+ exclude: [ /[\/\\]build[\/\\]/ ],
67
67
  } );
68
68
 
69
69
  defaultConfig.addPlugin( syncDirectory );
@@ -0,0 +1,73 @@
1
+ const MiniCSSExtractPlugin = require( 'mini-css-extract-plugin' );
2
+ const RtlCssPlugin = require( 'rtlcss-webpack-plugin' );
3
+ const RemoveEmptyScriptsPlugin = require( 'webpack-remove-empty-scripts' );
4
+ const SyncDirectoryWebpackPlugin = require( '../helpers/sync-directory-webpack-plugin' );
5
+ const CleanWebpackPlugin = require( '../helpers/clean-webpack-plugin' );
6
+ const findFreePort = require( 'find-free-port-sync' );
7
+ const { resolve } = require( 'node:path' );
8
+ const {
9
+ Config,
10
+ defaultConfigWP,
11
+ modulesConfigWP,
12
+ } = require( '../helpers/webpack' );
13
+ const rootPath = process.cwd().replace( /\\/g, '/' );
14
+ const outputPath = process.env.WP_CONTENT_DIR
15
+ ? resolve( process.env.WP_CONTENT_DIR, 'plugins/the-builder' )
16
+ : rootPath;
17
+
18
+ const port =
19
+ process.env.THEME_BLOCK_DEV_SERVER_PORT ||
20
+ findFreePort( { start: 11000, end: 11999 } );
21
+
22
+ const defaultConfig = new Config( defaultConfigWP, 'default', port )
23
+ .addEntries( 'src/blocks/**/styles/*.{pc,sc,sa,c}ss' )
24
+ .addEntries( 'src/*.{ts,tsx}' )
25
+ .removePlugin( RtlCssPlugin )
26
+ .replacePlugin(
27
+ new MiniCSSExtractPlugin( {
28
+ filename( pathData ) {
29
+ return `${ pathData.chunk.name.replace(
30
+ '/scripts/',
31
+ '/styles/'
32
+ ) }.css`;
33
+ },
34
+ } )
35
+ )
36
+ .addPlugin(
37
+ new CleanWebpackPlugin( {
38
+ patterns: [
39
+ resolve( outputPath, 'build/**/*' ),
40
+ '!' + resolve( outputPath, 'build/**/module.*' ),
41
+ ],
42
+ } )
43
+ );
44
+
45
+ if ( ! Config.hasDevServer( defaultConfigWP ) ) {
46
+ defaultConfig.addPlugin(
47
+ // For styles remove JS and styles .asset.php
48
+ new RemoveEmptyScriptsPlugin()
49
+ );
50
+ }
51
+
52
+ const modulesConfig = new Config( modulesConfigWP, 'modules' ).addPlugin(
53
+ new CleanWebpackPlugin( {
54
+ patterns: [ resolve( outputPath, 'build/**/module.*' ) ],
55
+ } )
56
+ );
57
+
58
+ if ( process.env.WP_CONTENT_DIR ) {
59
+ const buildPath = resolve( outputPath, 'build' );
60
+ defaultConfigWP.output.path = buildPath;
61
+ modulesConfigWP.output.path = buildPath;
62
+
63
+ const syncDirectory = new SyncDirectoryWebpackPlugin( {
64
+ sourceDir: rootPath,
65
+ targetDir: outputPath,
66
+ exclude: [ /[\/\\]build[\/\\]/ ],
67
+ } );
68
+
69
+ defaultConfig.addPlugin( syncDirectory );
70
+ modulesConfig.addPlugin( syncDirectory );
71
+ }
72
+
73
+ module.exports = [ defaultConfig.get(), modulesConfig.get() ];
@@ -38,7 +38,7 @@ const defaultConfig = new Config( defaultConfigWP, 'default', port )
38
38
  new CleanWebpackPlugin( {
39
39
  patterns: [
40
40
  resolve( outputPath, 'build/**/*' ),
41
- '!' + resolve( outputPath, 'build/modules/**/*' ),
41
+ '!' + resolve( outputPath, 'build/scripts/modules/**/*' ),
42
42
  ],
43
43
  } )
44
44
  )
@@ -126,7 +126,7 @@ if ( process.env.WP_CONTENT_DIR ) {
126
126
  const syncDirectory = new SyncDirectoryWebpackPlugin( {
127
127
  sourceDir: rootPath,
128
128
  targetDir: outputPath,
129
- exclude: [ '/build/' ],
129
+ exclude: [ /[\/\\]build[\/\\]/ ],
130
130
  } );
131
131
 
132
132
  defaultConfig.addPlugin( syncDirectory );