@sumotto/configs 0.0.19 → 0.0.21

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.19",
3
+ "version": "0.0.21",
4
4
  "description": "Configs for my work",
5
5
  "scripts": {
6
6
  "release": "np --yolo"
@@ -10,7 +10,10 @@ const {
10
10
  defaultConfigWP,
11
11
  modulesConfigWP,
12
12
  } = require( '../helpers/webpack' );
13
- const root = process.cwd().replace( /\\/g, '/' );
13
+ const rootPath = process.cwd().replace( /\\/g, '/' );
14
+ const outputPath = process.env.WP_CONTENT_DIR
15
+ ? resolve( process.env.WP_CONTENT_DIR, 'plugins/theme-blocks' )
16
+ : rootPath;
14
17
 
15
18
  const port =
16
19
  process.env.THEME_BLOCK_DEV_SERVER_PORT ||
@@ -33,15 +36,8 @@ const defaultConfig = new Config( defaultConfigWP, 'default', port )
33
36
  .addPlugin(
34
37
  new CleanWebpackPlugin( {
35
38
  patterns: [
36
- resolve(
37
- process.env.WP_CONTENT_DIR,
38
- 'plugins/theme-blocks/build/**/*'
39
- ),
40
- '!' +
41
- resolve(
42
- process.env.WP_CONTENT_DIR,
43
- 'plugins/theme-blocks/build/**/module.*'
44
- ),
39
+ resolve( outputPath, 'build/**/*' ),
40
+ '!' + resolve( outputPath, 'build/**/module.*' ),
45
41
  ],
46
42
  } )
47
43
  );
@@ -55,29 +51,18 @@ if ( ! Config.hasDevServer( defaultConfigWP ) ) {
55
51
 
56
52
  const modulesConfig = new Config( modulesConfigWP, 'modules' ).addPlugin(
57
53
  new CleanWebpackPlugin( {
58
- patterns: [
59
- resolve(
60
- process.env.WP_CONTENT_DIR,
61
- 'plugins/theme-blocks/build/**/module.*'
62
- ),
63
- ],
54
+ patterns: [ resolve( outputPath, 'build/**/module.*' ) ],
64
55
  } )
65
56
  );
66
57
 
67
58
  if ( process.env.WP_CONTENT_DIR ) {
68
- const buildPath = resolve(
69
- process.env.WP_CONTENT_DIR,
70
- 'plugins/theme-blocks/build'
71
- );
59
+ const buildPath = resolve( outputPath, 'build' );
72
60
  defaultConfigWP.output.path = buildPath;
73
61
  modulesConfigWP.output.path = buildPath;
74
62
 
75
63
  const syncDirectory = new SyncDirectoryWebpackPlugin( {
76
- sourceDir: root,
77
- targetDir: resolve(
78
- process.env.WP_CONTENT_DIR,
79
- 'plugins/theme-blocks'
80
- ),
64
+ sourceDir: rootPath,
65
+ targetDir: outputPath,
81
66
  exclude: [ /build/ ],
82
67
  } );
83
68
 
@@ -68,18 +68,19 @@ modulesConfig.entry = {
68
68
  defaultConfig.name = 'default';
69
69
  modulesConfig.name = 'modules';
70
70
 
71
- defaultConfig.output.path = path.resolve( __dirname, 'build/scripts' );
72
- modulesConfig.output.path = path.resolve( __dirname, 'build/modules' );
71
+ defaultConfig.output.path = path.resolve( process.cwd(), 'build/scripts' );
72
+ modulesConfig.output.path = path.resolve( process.cwd(), 'build/modules' );
73
73
 
74
74
  const reactJSXRuntimeConfig = {
75
75
  name: 'react',
76
+ mode: defaultConfig.mode,
76
77
  entry: {
77
78
  'react-jsx-runtime': {
78
79
  import: 'react/jsx-runtime',
79
80
  },
80
81
  },
81
82
  output: {
82
- path: path.resolve( __dirname, 'build/polyfill' ),
83
+ path: path.resolve( process.cwd(), 'build/polyfill' ),
83
84
  filename: 'react-jsx-runtime.js',
84
85
  library: {
85
86
  name: 'ReactJSXRuntime',
@@ -11,7 +11,10 @@ const {
11
11
  defaultConfigWP,
12
12
  modulesConfigWP,
13
13
  } = require( '../helpers/webpack' );
14
- const root = process.cwd().replace( /\\/g, '/' );
14
+ const rootPath = process.cwd().replace( /\\/g, '/' );
15
+ const outputPath = process.env.WP_CONTENT_DIR
16
+ ? resolve( process.env.WP_CONTENT_DIR, 'themes/theme-child' )
17
+ : rootPath;
15
18
 
16
19
  const port =
17
20
  process.env.THEME_DEV_SERVER_PORT ||
@@ -27,22 +30,15 @@ const defaultConfig = new Config( defaultConfigWP, 'default', port )
27
30
  const last = rule.use.length - 1;
28
31
 
29
32
  rule.use[ last ].options.sassOptions = {
30
- includePaths: [ resolve( root, 'src/styles/partials' ) ],
33
+ includePaths: [ resolve( rootPath, 'src/styles/partials' ) ],
31
34
  };
32
35
  } )
33
36
  .removePlugin( RtlCssPlugin )
34
37
  .addPlugin(
35
38
  new CleanWebpackPlugin( {
36
39
  patterns: [
37
- resolve(
38
- process.env.WP_CONTENT_DIR,
39
- 'themes/theme-child/build/**/*'
40
- ),
41
- '!' +
42
- resolve(
43
- process.env.WP_CONTENT_DIR,
44
- 'themes/theme-child/build/modules/**/*'
45
- ),
40
+ resolve( outputPath, 'build/**/*' ),
41
+ '!' + resolve( outputPath, 'build/modules/**/*' ),
46
42
  ],
47
43
  } )
48
44
  )
@@ -118,26 +114,18 @@ const modulesConfig = new Config( modulesConfigWP, 'modules' )
118
114
  .addEntries( 'src/scripts/modules/*.{j,t}s' )
119
115
  .addPlugin(
120
116
  new CleanWebpackPlugin( {
121
- patterns: [
122
- resolve(
123
- process.env.WP_CONTENT_DIR,
124
- 'themes/theme-child/build/scripts/modules/**/*'
125
- ),
126
- ],
117
+ patterns: [ resolve( outputPath, '/build/scripts/modules/**/*' ) ],
127
118
  } )
128
119
  );
129
120
 
130
121
  if ( process.env.WP_CONTENT_DIR ) {
131
- const buildPath = resolve(
132
- process.env.WP_CONTENT_DIR,
133
- 'themes/theme-child/build'
134
- );
122
+ const buildPath = resolve( outputPath, 'build' );
135
123
  defaultConfigWP.output.path = buildPath;
136
124
  modulesConfigWP.output.path = buildPath;
137
125
 
138
126
  const syncDirectory = new SyncDirectoryWebpackPlugin( {
139
- sourceDir: root,
140
- targetDir: resolve( process.env.WP_CONTENT_DIR, 'themes/theme-child' ),
127
+ sourceDir: rootPath,
128
+ targetDir: outputPath,
141
129
  exclude: [ '/build/' ],
142
130
  } );
143
131