@machtwatch/react-script 1.2.11-alpha.23 → 1.2.11-alpha.24

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.
@@ -106,7 +106,7 @@ switch (script) {
106
106
  delete require.cache[__filename];
107
107
 
108
108
  // eslint-disable-next-line global-require, import/no-dynamic-require
109
- const module = require(path.resolve(`${__dirname }/../scripts/${ script}`));
109
+ const module = require(path.resolve(`${__dirname}/../scripts/${script}`));
110
110
 
111
111
  run(module).catch((err) => {
112
112
  console.error(err.stack);
@@ -155,6 +155,6 @@ switch (script) {
155
155
  }
156
156
 
157
157
  default:
158
- console.log(`Unknown script "${ script }".`);
158
+ console.log(`Unknown script "${script}".`);
159
159
  break;
160
160
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@machtwatch/react-script",
3
- "version": "1.2.11-alpha.23",
3
+ "version": "1.2.11-alpha.24",
4
4
  "description": "Machtwatch React script",
5
5
  "author": "Danny Reza Miloen <danny@machtwatch.co.id>",
6
6
  "contributors": [],
@@ -64,7 +64,7 @@
64
64
  "browser-sync": "^2.26.7",
65
65
  "child_process": "^1.0.2",
66
66
  "compression-webpack-plugin": "^10.0.0",
67
- "config": "^3.2.2",
67
+ "config": "^4.1.1",
68
68
  "core-js": "^3.23.3",
69
69
  "css-loader": "^6.7.1",
70
70
  "css-minimizer-webpack-plugin": "^4.0.0",
@@ -3,7 +3,7 @@ const path = require('path');
3
3
  const glob = require('glob-all');
4
4
  const webpack = require('webpack');
5
5
  const nodeExternals = require('webpack-node-externals');
6
- const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
6
+ const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
7
7
  const AssetsPlugin = require('assets-webpack-plugin');
8
8
  const TerserPlugin = require('terser-webpack-plugin');
9
9
  const MiniCssExtractPlugin = require('mini-css-extract-plugin');
@@ -29,7 +29,7 @@ const visitedFrameworkPackages = new Set();
29
29
 
30
30
  const {
31
31
  argv,
32
- env : {
32
+ env: {
33
33
  NODE_ENV,
34
34
  APPHOST,
35
35
  PUBLIC_PATH,
@@ -68,7 +68,7 @@ console.log(
68
68
  isAnalyze,
69
69
  config_compiler: config.compiler_public_path,
70
70
  compression: USE_STATIC_COMPRESSION,
71
- }).reduce((a, [k, v]) => a += `${k}: ${v}\n`, '\n')
71
+ }).reduce((a, [k, v]) => a += `${k}: ${v}\n`, '\n')
72
72
  );
73
73
 
74
74
  //Generate SW Environment Config
@@ -86,7 +86,7 @@ class GenerateSWEnvPlugin {
86
86
  }
87
87
  `
88
88
  );
89
- fs.writeFileSync(`${paths.appBuild }/public/env.js`,
89
+ fs.writeFileSync(`${paths.appBuild}/public/env.js`,
90
90
  `
91
91
  var env = {
92
92
  FIREBASE_SENDER_ID: ${FIREBASE_SENDER_ID}
@@ -118,7 +118,7 @@ const addPackagePath = (packageName, relativeToPath) => {
118
118
  const directory = path.join(packageJsonPath, '../');
119
119
 
120
120
  // Returning from the function in case the directory has already been added and traversed
121
- if (topLevelFrameworkPaths.includes(directory)) {return;}
121
+ if (topLevelFrameworkPaths.includes(directory)) { return; }
122
122
  topLevelFrameworkPaths.push(directory);
123
123
 
124
124
  const dependencies = require(packageJsonPath).dependencies || {};
@@ -136,13 +136,13 @@ for (const packageName of ['react', 'react-dom', 'react-router', 'scheduler', 'u
136
136
  }
137
137
 
138
138
  const isModuleCSS = module => (
139
- // mini-css-extract-plugin
140
- module.type === 'css/mini-extract' ||
141
- // extract-css-chunks-webpack-plugin (old)
142
- module.type === 'css/extract-chunks' ||
143
- // extract-css-chunks-webpack-plugin (new)
144
- module.type === 'css/extract-css-chunks'
145
- );
139
+ // mini-css-extract-plugin
140
+ module.type === 'css/mini-extract' ||
141
+ // extract-css-chunks-webpack-plugin (old)
142
+ module.type === 'css/extract-chunks' ||
143
+ // extract-css-chunks-webpack-plugin (new)
144
+ module.type === 'css/extract-css-chunks'
145
+ );
146
146
 
147
147
  //
148
148
  // Common configuration chunk to be used for both
@@ -279,7 +279,7 @@ const styleLoaders = ({ isClient }) => [
279
279
  options: {
280
280
  modules: {
281
281
  exportOnlyLocals: !isClient,
282
- localIdentName:'[local]',
282
+ localIdentName: '[local]',
283
283
  },
284
284
  importLoaders: 2,
285
285
  },
@@ -324,7 +324,7 @@ const styleLoaders = ({ isClient }) => [
324
324
  lessOptions: {
325
325
  javascriptEnabled: true,
326
326
  paths: [
327
- `${paths.appSrc}/styles` ,
327
+ `${paths.appSrc}/styles`,
328
328
  `${paths.appPath}/node_modules/@machtwatch/react-ui`,
329
329
  ],
330
330
  }
@@ -360,8 +360,8 @@ const clientConfig = {
360
360
 
361
361
  return resource
362
362
  ? topLevelFrameworkPaths.some((pkgPath) =>
363
- resource.startsWith(pkgPath)
364
- )
363
+ resource.startsWith(pkgPath)
364
+ )
365
365
  : false;
366
366
  },
367
367
  priority: 40,
@@ -477,13 +477,70 @@ const clientConfig = {
477
477
  rules: [
478
478
  ...baseClientConfig.module.rules,
479
479
  {
480
- test: /\.(css|less)$/,
480
+ test: /\.css$/,
481
481
  use: [
482
+ MiniCssExtractPlugin.loader,
483
+ {
484
+ loader: 'css-loader',
485
+ options: {
486
+ modules: {
487
+ exportOnlyLocals: false,
488
+ localIdentName: '[local]',
489
+ },
490
+ importLoaders: 1,
491
+ },
492
+ },
482
493
  {
483
- loader: MiniCssExtractPlugin.loader,
494
+ loader: 'postcss-loader',
495
+ options: {
496
+ postcssOptions: {
497
+ ident: 'postcss',
498
+ config: false,
499
+ plugins: [
500
+ [
501
+ 'postcss-import',
502
+ {
503
+ addModulesDirectories: [
504
+ path.resolve(__dirname, '../node_modules'),
505
+ `${paths.appPath}/node_modules`
506
+ ],
507
+ root: `${paths.appSrc}/styles/`
508
+ }
509
+ ],
510
+ [
511
+ 'postcss-preset-env',
512
+ {
513
+ autoprefixer: { flexbox: 'no-2009' },
514
+ stage: 3,
515
+ browsers: pkg.browserslist,
516
+ }
517
+ ],
518
+ 'tailwindcss',
519
+ 'postcss-modules-values',
520
+ 'postcss-flexbugs-fixes',
521
+ ],
522
+ },
523
+ },
484
524
  },
485
- ...(styleLoaders({ isClient: true }))
486
- ]
525
+ ],
526
+ },
527
+ {
528
+ test: /\.less$/,
529
+ use: [
530
+ MiniCssExtractPlugin.loader,
531
+ ...styleLoaders({ isClient: true }).filter(
532
+ (loader) => loader.loader !== 'less-loader'
533
+ ),
534
+ {
535
+ loader: 'less-loader',
536
+ options: {
537
+ lessOptions: {
538
+ javascriptEnabled: true,
539
+ paths: [`${paths.appSrc}/styles`],
540
+ },
541
+ },
542
+ },
543
+ ],
487
544
  }
488
545
  ]
489
546
  },
@@ -659,18 +716,26 @@ const serverConfig = {
659
716
  },
660
717
  module: {
661
718
  ...baseServerConfig.module,
662
- rules:[
719
+ rules: [
663
720
  ...baseServerConfig.module.rules,
664
721
  {
665
- test: /\.(css|less)$/,
722
+ test: /\.css$/,
723
+ use: styleLoaders({ isClient: false }).filter(
724
+ (loader) => loader.loader !== 'less-loader'
725
+ ),
726
+ },
727
+ {
728
+ test: /\.less$/,
666
729
  use: styleLoaders({ isClient: false }),
667
730
  },
668
731
  ],
669
732
  },
670
733
  externalsPresets: { node: true },
671
734
  externals: [
735
+ nodeExternals({
736
+ allowlist: [/^driver\.js/],
737
+ }),
672
738
  /^\.\/assets\.json$/,
673
- nodeExternals({ allowlist: /(@machtwatch\/react-ui|\.(css|less|scss|sss)$)/i })
674
739
  ],
675
740
  plugins: [
676
741
  ...baseServerConfig.plugins,