@sumotto/configs 0.0.3 → 0.0.5

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.3",
3
+ "version": "0.0.5",
4
4
  "description": "Configs for my work",
5
5
  "scripts": {
6
6
  "release": "np --yolo"
@@ -26,6 +26,7 @@
26
26
  "clean-webpack-plugin": "^4.0.0",
27
27
  "copy-webpack-plugin": "^12.0.2",
28
28
  "dotenv": "^16.4.5",
29
+ "find-free-port-sync": "^1.0.0",
29
30
  "glob": "^10.4.1",
30
31
  "image-minimizer-webpack-plugin": "^4.0.1",
31
32
  "mini-css-extract-plugin": "^2.9.0",
@@ -1,18 +1,20 @@
1
1
  const MiniCSSExtractPlugin = require( 'mini-css-extract-plugin' );
2
2
  const RtlCssPlugin = require( 'rtlcss-webpack-plugin' );
3
3
  const { CleanWebpackPlugin } = require( 'clean-webpack-plugin' );
4
+ const RemoveEmptyScriptsPlugin = require( 'webpack-remove-empty-scripts' );
5
+ const findFreePort = require( 'find-free-port-sync' );
4
6
  const {
5
7
  Config,
6
8
  defaultConfigWP,
7
9
  modulesConfigWP,
8
10
  } = require( '../helpers/webpack' );
9
11
 
10
- const defaultConfig = new Config(
11
- defaultConfigWP,
12
- 'default',
13
- process.env.THEME_BLOCK_DEV_SERVER_PORT || 'auto'
14
- )
15
- .addEntries( 'src/**/styles/*.{pc,sc,sa,c}ss' )
12
+ const port =
13
+ process.env.THEME_BLOCK_DEV_SERVER_PORT ||
14
+ findFreePort( { start: 11000, end: 11999 } );
15
+
16
+ const defaultConfig = new Config( defaultConfigWP, 'default', port )
17
+ .addEntries( 'src/blocks/**/styles/*.{pc,sc,sa,c}ss' )
16
18
  .addEntries( 'src/index.{ts,tsx}' )
17
19
  .removePlugin( RtlCssPlugin )
18
20
  .replacePlugin(
@@ -27,10 +29,16 @@ const defaultConfig = new Config(
27
29
  )
28
30
  .addPlugin(
29
31
  new CleanWebpackPlugin( {
30
- cleanOnceBeforeBuildPatterns: [ '!**/*module*,' ],
32
+ cleanOnceBeforeBuildPatterns: [ '**/*', '!**/*module*,' ],
31
33
  cleanStaleWebpackAssets: false,
32
34
  } ),
33
35
  'before'
36
+ )
37
+ .addPlugin(
38
+ // For styles remove JS and styles .asset.php
39
+ new RemoveEmptyScriptsPlugin( {
40
+ enabled: ! Config.hasDevServer( defaultConfigWP ),
41
+ } )
34
42
  );
35
43
 
36
44
  const modulesConfig = new Config( modulesConfigWP, 'modules' );
@@ -4,17 +4,18 @@ const RemoveEmptyScriptsPlugin = require( 'webpack-remove-empty-scripts' );
4
4
  const RtlCssPlugin = require( 'rtlcss-webpack-plugin' );
5
5
  const ImageMinimizerPlugin = require( 'image-minimizer-webpack-plugin' );
6
6
  const { resolve } = require( 'node:path' );
7
+ const findFreePort = require( 'find-free-port-sync' );
7
8
  const {
8
9
  Config,
9
10
  defaultConfigWP,
10
11
  modulesConfigWP,
11
12
  } = require( '../helpers/webpack' );
12
13
 
13
- const defaultConfig = new Config(
14
- defaultConfigWP,
15
- 'default',
16
- process.env.THEME_DEV_SERVER_PORT || 'auto'
17
- )
14
+ const port =
15
+ process.env.THEME_DEV_SERVER_PORT ||
16
+ findFreePort( { start: 10000, end: 10999 } );
17
+
18
+ const defaultConfig = new Config( defaultConfigWP, 'default', port )
18
19
  .resetEntries()
19
20
  .addEntries(
20
21
  'src/styles/{*.{pc,sc,sa,c}ss,{blocks,variations,patterns}/**/*.{pc,sc,sa,c}ss}'
@@ -31,7 +32,7 @@ const defaultConfig = new Config(
31
32
  .removePlugin( RtlCssPlugin )
32
33
  .addPlugin(
33
34
  new CleanWebpackPlugin( {
34
- cleanOnceBeforeBuildPatterns: [ '!modules/**' ],
35
+ cleanOnceBeforeBuildPatterns: [ '**/*', '!modules/**' ],
35
36
  cleanStaleWebpackAssets: false,
36
37
  } ),
37
38
  'before'