@machtwatch/react-script 1.2.11-alpha.31 → 1.2.11-alpha.32
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/config/babel/babel-custom-loader.js +61 -65
- package/config/jest/createJestConfig.js +1 -4
- package/config/jest/jest-setup.js +3 -0
- package/package.json +7 -9
- package/scripts/build.js +4 -14
- package/scripts/lib/webpackHotDevClient.js +25 -25
- package/scripts/start.js +7 -19
- package/scripts/test.js +18 -29
- package/scripts/utils/clean.js +3 -1
- package/scripts/webpack.config.js +179 -159
|
@@ -1,70 +1,66 @@
|
|
|
1
1
|
module.exports = () => ({
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
2
|
+
customOptions({ transform_runtime, ...loader }) {
|
|
3
|
+
return {
|
|
4
|
+
loader,
|
|
5
|
+
custom: { ...transform_runtime }
|
|
6
|
+
};
|
|
7
|
+
},
|
|
8
|
+
config(cfg) {
|
|
9
|
+
return {
|
|
10
|
+
...cfg.options,
|
|
11
|
+
presets: [
|
|
12
|
+
[
|
|
13
|
+
require('@babel/preset-env'),
|
|
14
|
+
{
|
|
15
|
+
modules: false,
|
|
16
|
+
useBuiltIns: 'usage',
|
|
17
|
+
corejs: '3.22'
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
require('@babel/preset-react'),
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
...(cfg.options.isClient && !cfg.options.compact ? [
|
|
53
|
-
require.resolve('react-refresh/babel')
|
|
54
|
-
] : [
|
|
22
|
+
],
|
|
23
|
+
plugins: [
|
|
24
|
+
require('@babel/plugin-transform-runtime'),
|
|
25
|
+
require('@babel/plugin-proposal-function-bind'),
|
|
26
|
+
require('@babel/plugin-proposal-export-default-from'),
|
|
27
|
+
require('@babel/plugin-proposal-export-namespace-from'),
|
|
28
|
+
require('@babel/plugin-proposal-throw-expressions'),
|
|
29
|
+
require('@babel/plugin-syntax-dynamic-import'),
|
|
30
|
+
require('@babel/plugin-proposal-json-strings'),
|
|
31
|
+
require('@loadable/babel-plugin'),
|
|
32
|
+
[require('babel-plugin-transform-imports'), {
|
|
33
|
+
'@machtwatch/react-ui': {
|
|
34
|
+
transform: '@machtwatch/react-ui/lib/${member}',
|
|
35
|
+
preventFullImport: true
|
|
36
|
+
}
|
|
37
|
+
}],
|
|
38
|
+
[require('@babel/plugin-proposal-decorators'), {
|
|
39
|
+
legacy: true
|
|
40
|
+
}],
|
|
41
|
+
[require('@babel/plugin-proposal-optional-chaining'), {
|
|
42
|
+
loose: true
|
|
43
|
+
}],
|
|
44
|
+
[require('@babel/plugin-proposal-class-properties'), {
|
|
45
|
+
loose: true
|
|
46
|
+
}],
|
|
47
|
+
[require('@babel/plugin-proposal-private-methods'), { loose: true }],
|
|
48
|
+
[require('@babel/plugin-proposal-private-property-in-object'), { loose: true }],
|
|
49
|
+
[require('babel-plugin-add-module-exports'), {
|
|
50
|
+
addDefaultProperty: true
|
|
51
|
+
}],
|
|
55
52
|
...(cfg.options.compact ? [
|
|
56
53
|
require('@babel/plugin-transform-react-inline-elements'),
|
|
57
54
|
require('@babel/plugin-transform-react-constant-elements')
|
|
58
|
-
] : [])
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
});
|
|
55
|
+
] : []),
|
|
56
|
+
...(cfg.options.plugins || [])
|
|
57
|
+
],
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
result(result) {
|
|
61
|
+
return {
|
|
62
|
+
...result,
|
|
63
|
+
code: `${result.code} \n// Generated by babel-custom-loader`
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
});
|
|
@@ -4,7 +4,7 @@ const path = require('path');
|
|
|
4
4
|
const fs = require('fs');
|
|
5
5
|
const merge = require('deepmerge');
|
|
6
6
|
|
|
7
|
-
module.exports = (resolve, rootDir, srcRoots
|
|
7
|
+
module.exports = (resolve, rootDir, srcRoots) => {
|
|
8
8
|
const toRelRootDir = f => '<rootDir>/' + path.relative(rootDir || '', f);
|
|
9
9
|
const extendedPath = path.join(process.cwd(), 'extended-jest.config.js');
|
|
10
10
|
|
|
@@ -26,9 +26,6 @@ module.exports = (resolve, rootDir, srcRoots, appConfig) => {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
const config = {
|
|
29
|
-
globals: {
|
|
30
|
-
CONFIG: appConfig && (appConfig.globals || appConfig),
|
|
31
|
-
},
|
|
32
29
|
setupFiles: [resolve('scripts/utils/polyfills.js')],
|
|
33
30
|
testMatch: [
|
|
34
31
|
"<rootDir>/src/shared/**/*.(spec|test).{js,jsx,mjs}"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@machtwatch/react-script",
|
|
3
|
-
"version": "1.2.11-alpha.
|
|
3
|
+
"version": "1.2.11-alpha.32",
|
|
4
4
|
"description": "Machtwatch React script",
|
|
5
5
|
"author": "Danny Reza Miloen <danny@machtwatch.co.id>",
|
|
6
6
|
"contributors": [],
|
|
@@ -51,10 +51,9 @@
|
|
|
51
51
|
"@babel/preset-react": "^7.17.12",
|
|
52
52
|
"@loadable/babel-plugin": "^5.13.2",
|
|
53
53
|
"@loadable/webpack-plugin": "^5.15.2",
|
|
54
|
-
"@pmmmwh/react-refresh-webpack-plugin": "0.6.2",
|
|
55
54
|
"@svgr/webpack": "^6.2.1",
|
|
56
55
|
"@testing-library/jest-dom": "^5.12.0",
|
|
57
|
-
"@testing-library/react": "
|
|
56
|
+
"@testing-library/react": "^11.2.7",
|
|
58
57
|
"assets-webpack-plugin": "7.1.1",
|
|
59
58
|
"autoprefixer": "^10.4.20",
|
|
60
59
|
"babel-jest": "^26.3.0",
|
|
@@ -65,6 +64,7 @@
|
|
|
65
64
|
"browser-sync": "^2.26.7",
|
|
66
65
|
"child_process": "^1.0.2",
|
|
67
66
|
"compression-webpack-plugin": "^10.0.0",
|
|
67
|
+
"config": "^3.3.9",
|
|
68
68
|
"core-js": "^3.23.3",
|
|
69
69
|
"css-loader": "^7.1.2",
|
|
70
70
|
"css-minimizer-webpack-plugin": "^4.0.0",
|
|
@@ -80,6 +80,8 @@
|
|
|
80
80
|
"imagemin-webp-webpack-plugin": "^3.3.6",
|
|
81
81
|
"intersection-observer": "^0.5.1",
|
|
82
82
|
"jest": "^26.4.2",
|
|
83
|
+
"less": "^4.2.1",
|
|
84
|
+
"less-loader": "^12.2.0",
|
|
83
85
|
"mini-css-extract-plugin": "^2.6.1",
|
|
84
86
|
"mkdirp": "^0.5.1",
|
|
85
87
|
"null-loader": "^4.0.1",
|
|
@@ -89,14 +91,10 @@
|
|
|
89
91
|
"postcss-import": "^14.1.0",
|
|
90
92
|
"postcss-loader": "^8.1.1",
|
|
91
93
|
"postcss-preset-env": "^7.7.1",
|
|
92
|
-
"process": "0.11.10",
|
|
93
94
|
"promise": "^8.0.2",
|
|
94
95
|
"purgecss-webpack-plugin": "^4.1.3",
|
|
95
|
-
"react": "18.3.1",
|
|
96
96
|
"react-dev-utils": "^12.0.1",
|
|
97
|
-
"react-
|
|
98
|
-
"react-error-overlay": "6.0.11",
|
|
99
|
-
"react-refresh": "0.18.0",
|
|
97
|
+
"react-error-overlay": "6.0.9",
|
|
100
98
|
"recluster": "^0.4.5",
|
|
101
99
|
"regenerator-runtime": "^0.13.3",
|
|
102
100
|
"rimraf": "^2.6.3",
|
|
@@ -105,7 +103,7 @@
|
|
|
105
103
|
"speed-measure-webpack-plugin": "^1.5.0",
|
|
106
104
|
"style-loader": "^4.0.0",
|
|
107
105
|
"stylelint": "^16.10.0",
|
|
108
|
-
"stylelint-config-recommended": "^
|
|
106
|
+
"stylelint-config-recommended-less": "^3.0.1",
|
|
109
107
|
"stylelint-webpack-plugin": "^5.0.1",
|
|
110
108
|
"tailwindcss": "^3.4.17",
|
|
111
109
|
"terser": "^5.14.1",
|
package/scripts/build.js
CHANGED
|
@@ -5,18 +5,14 @@ const run = require('./utils/run');
|
|
|
5
5
|
const clean = require('./utils/clean');
|
|
6
6
|
const copy = require('./utils/copy');
|
|
7
7
|
const pkg = require('../package.json');
|
|
8
|
-
const
|
|
9
|
-
const { createRequire } = require('module');
|
|
10
|
-
|
|
11
|
-
const requireApp = createRequire(`${paths.appPath}/package.json`);
|
|
12
|
-
const { loadConfig } = requireApp('c12');
|
|
8
|
+
const webpackConfig = require('./webpack.config');
|
|
13
9
|
|
|
14
10
|
/**
|
|
15
11
|
* Compiles the project from source files into a distributable
|
|
16
12
|
* format and copies it to the output (build) folder.
|
|
17
13
|
*/
|
|
18
14
|
|
|
19
|
-
function bundle(
|
|
15
|
+
function bundle() {
|
|
20
16
|
return new Promise((resolve, reject) => {
|
|
21
17
|
webpack(webpackConfig).run((err, stats) => {
|
|
22
18
|
if (err) {
|
|
@@ -31,15 +27,9 @@ function bundle(webpackConfig) {
|
|
|
31
27
|
}
|
|
32
28
|
|
|
33
29
|
async function build() {
|
|
34
|
-
|
|
35
|
-
cwd: paths.appPath,
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
const webpackConfig = await require('./webpack.config')(config);
|
|
39
|
-
|
|
40
|
-
await run(clean, config);
|
|
30
|
+
await run(clean);
|
|
41
31
|
await run(copy);
|
|
42
|
-
await run(bundle
|
|
32
|
+
await run(bundle);
|
|
43
33
|
|
|
44
34
|
if (process.argv.includes('--docker')) {
|
|
45
35
|
cp.spawnSync('docker', ['build', '-t', pkg.name, '.'], { stdio: 'inherit' })
|
|
@@ -10,38 +10,38 @@ const {
|
|
|
10
10
|
stopReportingRuntimeErrors,
|
|
11
11
|
} = require('react-error-overlay');
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
//
|
|
17
|
-
// fetch(
|
|
18
|
-
// // Keep in sync with react-dev-utils/errorOverlayMiddleware
|
|
19
|
-
// `${launchEditorEndpoint}?fileName=${fileName}&lineNumber=${lineNumber}`,
|
|
20
|
-
// );
|
|
21
|
-
// });
|
|
13
|
+
setEditorHandler(errorLocation => {
|
|
14
|
+
const fileName = encodeURIComponent(errorLocation.fileName);
|
|
15
|
+
const lineNumber = encodeURIComponent(errorLocation.lineNumber || 1);
|
|
22
16
|
|
|
23
|
-
|
|
24
|
-
//
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
17
|
+
fetch(
|
|
18
|
+
// Keep in sync with react-dev-utils/errorOverlayMiddleware
|
|
19
|
+
`${launchEditorEndpoint}?fileName=${fileName}&lineNumber=${lineNumber}`,
|
|
20
|
+
);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
hotClient.useCustomOverlay({
|
|
24
|
+
showProblems(type, errors) {
|
|
25
|
+
const formatted = formatWebpackMessages({
|
|
26
|
+
errors,
|
|
27
|
+
warnings: [],
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
reportBuildError(formatted.errors[0]);
|
|
31
|
+
},
|
|
32
|
+
clear() {
|
|
33
|
+
dismissBuildError();
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
36
|
|
|
37
37
|
hotClient.setOptionsAndConnect({
|
|
38
38
|
name: 'client',
|
|
39
39
|
reload: true,
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
startReportingRuntimeErrors({
|
|
43
|
+
filename: '/assets/client.js',
|
|
44
|
+
});
|
|
45
45
|
|
|
46
46
|
if (module.hot) {
|
|
47
47
|
module.hot.dispose(stopReportingRuntimeErrors);
|
package/scripts/start.js
CHANGED
|
@@ -7,13 +7,11 @@ const webpackHotMiddleware = require('webpack-hot-middleware');
|
|
|
7
7
|
const errorOverlayMiddleware = require('react-dev-utils/errorOverlayMiddleware');
|
|
8
8
|
|
|
9
9
|
const paths = require('../config/paths');
|
|
10
|
-
|
|
10
|
+
const webpackConfig = require('./webpack.config');
|
|
11
11
|
const run = require('./utils/run');
|
|
12
12
|
const clean = require('./utils/clean');
|
|
13
|
-
const { createRequire } = require('module');
|
|
14
13
|
|
|
15
|
-
const
|
|
16
|
-
const { loadConfig } = requireApp('c12');
|
|
14
|
+
const config = require('config').util.loadFileConfigs(`${paths.appPath}/config`);
|
|
17
15
|
|
|
18
16
|
const { format } = run;
|
|
19
17
|
|
|
@@ -71,18 +69,12 @@ async function start() {
|
|
|
71
69
|
return server;
|
|
72
70
|
}
|
|
73
71
|
|
|
74
|
-
const { config } = await loadConfig({
|
|
75
|
-
cwd: paths.appPath,
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
const webpackConfig = await require('./webpack.config')(config);
|
|
79
|
-
|
|
80
72
|
server = express();
|
|
81
73
|
server.use(errorOverlayMiddleware());
|
|
82
74
|
server.use(express.static(paths.appPublic));
|
|
83
75
|
|
|
84
76
|
// Configure client-side hot module replacement
|
|
85
|
-
const clientConfig = webpackConfig.find(
|
|
77
|
+
const clientConfig = webpackConfig.find(config => config.name === 'client');
|
|
86
78
|
|
|
87
79
|
clientConfig.entry.client = [path.resolve(`${__dirname}/lib/webpackHotDevClient`)]
|
|
88
80
|
.concat(clientConfig.entry.client)
|
|
@@ -117,7 +109,7 @@ async function start() {
|
|
|
117
109
|
);
|
|
118
110
|
|
|
119
111
|
// Configure compilation
|
|
120
|
-
await run(clean
|
|
112
|
+
await run(clean);
|
|
121
113
|
|
|
122
114
|
const clientCompiler = webpack(clientConfig);
|
|
123
115
|
const serverCompiler = webpack(serverConfig);
|
|
@@ -195,14 +187,12 @@ async function start() {
|
|
|
195
187
|
checkForUpdate(true);
|
|
196
188
|
}
|
|
197
189
|
})
|
|
198
|
-
.catch(
|
|
190
|
+
.catch(error => {
|
|
199
191
|
if (['abort', 'fail'].includes(app.hot.status())) {
|
|
200
192
|
console.warn(`${hmrPrefix}Cannot apply update.`);
|
|
201
193
|
delete require.cache[require.resolve(`${paths.appBuild}/server`)];
|
|
202
194
|
// eslint-disable-next-line global-require, import/no-unresolved
|
|
203
|
-
|
|
204
|
-
const loaded = bundle instanceof Promise ? await bundle : bundle;
|
|
205
|
-
app = loaded.default;
|
|
195
|
+
app = require(`${paths.appBuild}/server`).default;
|
|
206
196
|
console.warn(`${hmrPrefix}App has been reloaded.`);
|
|
207
197
|
} else {
|
|
208
198
|
console.warn(
|
|
@@ -233,9 +223,7 @@ async function start() {
|
|
|
233
223
|
|
|
234
224
|
// Load compiled src/server.js as a middleware
|
|
235
225
|
// eslint-disable-next-line global-require, import/no-unresolved
|
|
236
|
-
|
|
237
|
-
const loaded = bundle instanceof Promise ? await bundle : bundle;
|
|
238
|
-
app = loaded.default;
|
|
226
|
+
app = require(`${paths.appBuild}/server`).default;
|
|
239
227
|
appPromiseIsResolved = true;
|
|
240
228
|
appPromiseResolve();
|
|
241
229
|
|
package/scripts/test.js
CHANGED
|
@@ -9,43 +9,32 @@ process.on('unhandledRejection', err => {
|
|
|
9
9
|
|
|
10
10
|
const jest = require('jest');
|
|
11
11
|
const path = require('path');
|
|
12
|
-
const { createRequire } = require('module');
|
|
13
12
|
|
|
14
13
|
const createJestConfig = require('../config/jest/createJestConfig');
|
|
15
14
|
const paths = require('../config/paths');
|
|
16
15
|
|
|
17
|
-
const requireApp = createRequire(`${paths.appPath}/package.json`);
|
|
18
|
-
const { loadConfig } = requireApp('c12');
|
|
19
|
-
|
|
20
16
|
require('../config/env');
|
|
21
17
|
|
|
22
|
-
|
|
23
|
-
const { config } = await loadConfig({ cwd: paths.appPath });
|
|
24
|
-
|
|
25
|
-
let argv = process.argv.slice(2);
|
|
26
|
-
|
|
27
|
-
if (argv.indexOf('--coverage') === -1 && argv.indexOf('--watchAll') === -1) {
|
|
28
|
-
argv.push('--watchAll');
|
|
29
|
-
}
|
|
18
|
+
let argv = process.argv.slice(2);
|
|
30
19
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
paths.srcPaths,
|
|
35
|
-
config
|
|
36
|
-
);
|
|
20
|
+
if (argv.indexOf('--coverage') === -1 && argv.indexOf('--watchAll') === -1) {
|
|
21
|
+
argv.push('--watchAll');
|
|
22
|
+
}
|
|
37
23
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
);
|
|
24
|
+
const jestConfig = createJestConfig(
|
|
25
|
+
relativePath => path.resolve(__dirname, '..', relativePath),
|
|
26
|
+
path.resolve(paths.appSrc, '..'),
|
|
27
|
+
paths.srcPaths
|
|
28
|
+
);
|
|
44
29
|
|
|
45
|
-
|
|
46
|
-
|
|
30
|
+
argv.push(
|
|
31
|
+
'--config',
|
|
32
|
+
JSON.stringify(
|
|
33
|
+
jestConfig
|
|
34
|
+
)
|
|
35
|
+
);
|
|
47
36
|
|
|
48
|
-
|
|
49
|
-
|
|
37
|
+
const testEnvironment = 'jsdom';
|
|
38
|
+
argv.push('--coverage', '--env', testEnvironment);
|
|
50
39
|
|
|
51
|
-
|
|
40
|
+
jest.run(argv);
|
package/scripts/utils/clean.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
const paths = require('../../config/paths');
|
|
2
|
+
const config = require('config').util.loadFileConfigs(paths.appPath + '/config');
|
|
1
3
|
const { cleanDir } = require('../lib/fs');
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* Cleans up the output (build) directory.
|
|
5
7
|
*/
|
|
6
|
-
function clean(
|
|
8
|
+
function clean() {
|
|
7
9
|
return Promise.all([
|
|
8
10
|
cleanDir('build/*', {
|
|
9
11
|
nosort: true,
|
|
@@ -17,10 +17,11 @@ const SimpleProgressWebpackPlugin = require('simple-progress-webpack-plugin');
|
|
|
17
17
|
const { SubresourceIntegrityPlugin } = require('webpack-subresource-integrity');
|
|
18
18
|
const crypto = require('crypto');
|
|
19
19
|
const SpeedMeasurePlugin = require('speed-measure-webpack-plugin');
|
|
20
|
-
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
|
|
21
20
|
|
|
22
21
|
const paths = require('../config/paths');
|
|
23
22
|
|
|
23
|
+
const config = require('config').util.loadFileConfigs(`${paths.appPath}/config`);
|
|
24
|
+
|
|
24
25
|
const pkg = require(`${paths.appPath}/package.json`);
|
|
25
26
|
const { name, version } = pkg;
|
|
26
27
|
const topLevelFrameworkPaths = [];
|
|
@@ -55,8 +56,6 @@ const mode = isDevEnv ? 'development' : 'production';
|
|
|
55
56
|
const isRuntimeDev = DEV_SERVER === 'true';
|
|
56
57
|
const smp = new SpeedMeasurePlugin({ disable: !MEASURE });
|
|
57
58
|
|
|
58
|
-
module.exports = async (config) => {
|
|
59
|
-
|
|
60
59
|
console.log(
|
|
61
60
|
`Building webpack project ${name}@${version}\n`,
|
|
62
61
|
Object.entries({
|
|
@@ -151,9 +150,6 @@ const isModuleCSS = module => (
|
|
|
151
150
|
// -----------------------------------------------------------------------------
|
|
152
151
|
const webpackConfig = ({ isClient }) => ({
|
|
153
152
|
mode,
|
|
154
|
-
experiments: {
|
|
155
|
-
topLevelAwait: true,
|
|
156
|
-
},
|
|
157
153
|
cache: { type: 'filesystem' },
|
|
158
154
|
|
|
159
155
|
output: {
|
|
@@ -171,13 +167,9 @@ const webpackConfig = ({ isClient }) => ({
|
|
|
171
167
|
'@hooks': path.resolve(paths.appSrc, 'hooks'),
|
|
172
168
|
'@components': path.resolve(paths.appSrc, 'components'),
|
|
173
169
|
'@baseComponents': path.resolve(paths.appSrc, 'base_components'),
|
|
174
|
-
'react/jsx-runtime':
|
|
175
|
-
'react/jsx-
|
|
176
|
-
'react/jsx-runtime.js': require.resolve('react/jsx-runtime'),
|
|
177
|
-
'react/jsx-dev-runtime.js': require.resolve('react/jsx-dev-runtime'),
|
|
178
|
-
...(isClient ? { c12: false } : {}),
|
|
170
|
+
'react/jsx-dev-runtime': 'react/jsx-dev-runtime.js',
|
|
171
|
+
'react/jsx-runtime': 'react/jsx-runtime.js'
|
|
179
172
|
},
|
|
180
|
-
conditionNames: ['import', 'require', 'node', 'default'],
|
|
181
173
|
},
|
|
182
174
|
|
|
183
175
|
resolveLoader: {
|
|
@@ -202,7 +194,6 @@ const webpackConfig = ({ isClient }) => ({
|
|
|
202
194
|
babelrc: false,
|
|
203
195
|
configFile: false,
|
|
204
196
|
compact: isProdEnv,
|
|
205
|
-
isClient,
|
|
206
197
|
cacheDirectory: true,
|
|
207
198
|
cacheCompression: false,
|
|
208
199
|
customize: path.resolve(__dirname, '../config/babel/babel-custom-loader.js'),
|
|
@@ -216,9 +207,6 @@ const webpackConfig = ({ isClient }) => ({
|
|
|
216
207
|
test: /\.mjs$/,
|
|
217
208
|
include: /node_modules/,
|
|
218
209
|
type: 'javascript/auto',
|
|
219
|
-
resolve: {
|
|
220
|
-
fullySpecified: false,
|
|
221
|
-
}
|
|
222
210
|
},
|
|
223
211
|
{
|
|
224
212
|
test: /\.(woff|woff2|eot|ttf|otf)$/i,
|
|
@@ -285,52 +273,65 @@ const webpackConfig = ({ isClient }) => ({
|
|
|
285
273
|
stats: 'minimal'
|
|
286
274
|
});
|
|
287
275
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
},
|
|
296
|
-
importLoaders: 2,
|
|
276
|
+
const styleLoaders = ({ isClient }) => [
|
|
277
|
+
{
|
|
278
|
+
loader: 'css-loader',
|
|
279
|
+
options: {
|
|
280
|
+
modules: {
|
|
281
|
+
exportOnlyLocals: !isClient,
|
|
282
|
+
localIdentName: '[local]',
|
|
297
283
|
},
|
|
284
|
+
importLoaders: 2,
|
|
298
285
|
},
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
[
|
|
317
|
-
'postcss-preset-env',
|
|
318
|
-
{
|
|
319
|
-
autoprefixer: {
|
|
320
|
-
flexbox: 'no-2009',
|
|
321
|
-
},
|
|
322
|
-
stage: 3,
|
|
323
|
-
browsers: pkg.browserslist
|
|
324
|
-
}
|
|
325
|
-
],
|
|
326
|
-
'tailwindcss',
|
|
327
|
-
'postcss-modules-values',
|
|
328
|
-
'postcss-flexbugs-fixes'
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
loader: require.resolve('postcss-loader'),
|
|
289
|
+
options: {
|
|
290
|
+
postcssOptions: {
|
|
291
|
+
ident: 'postcss',
|
|
292
|
+
config: false,
|
|
293
|
+
plugins: [
|
|
294
|
+
[
|
|
295
|
+
'postcss-import',
|
|
296
|
+
{
|
|
297
|
+
addModulesDirectories: [
|
|
298
|
+
path.resolve(__dirname, '../node_modules'),
|
|
299
|
+
`${paths.appPath}/node_modules`
|
|
300
|
+
],
|
|
301
|
+
root: `${paths.appSrc}/styles/`
|
|
302
|
+
}
|
|
329
303
|
],
|
|
330
|
-
|
|
304
|
+
'tailwindcss/nesting',
|
|
305
|
+
'tailwindcss',
|
|
306
|
+
[
|
|
307
|
+
'postcss-preset-env',
|
|
308
|
+
{
|
|
309
|
+
autoprefixer: {
|
|
310
|
+
flexbox: 'no-2009',
|
|
311
|
+
},
|
|
312
|
+
stage: 3,
|
|
313
|
+
browsers: pkg.browserslist
|
|
314
|
+
}
|
|
315
|
+
],
|
|
316
|
+
'postcss-modules-values',
|
|
317
|
+
'postcss-flexbugs-fixes'
|
|
318
|
+
],
|
|
331
319
|
},
|
|
332
320
|
},
|
|
333
|
-
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
loader: 'less-loader',
|
|
324
|
+
options: {
|
|
325
|
+
lessOptions: {
|
|
326
|
+
javascriptEnabled: true,
|
|
327
|
+
paths: [
|
|
328
|
+
`${paths.appSrc}/styles`,
|
|
329
|
+
`${paths.appPath}/node_modules/@machtwatch/react-ui`,
|
|
330
|
+
],
|
|
331
|
+
}
|
|
332
|
+
},
|
|
333
|
+
},
|
|
334
|
+
];
|
|
334
335
|
|
|
335
336
|
//
|
|
336
337
|
// Configuration for the client-side bundle (client.js)
|
|
@@ -471,7 +472,6 @@ const clientConfig = {
|
|
|
471
472
|
https: false,
|
|
472
473
|
util: false,
|
|
473
474
|
buffer: false,
|
|
474
|
-
assert: false,
|
|
475
475
|
}
|
|
476
476
|
},
|
|
477
477
|
module: {
|
|
@@ -508,6 +508,8 @@ const clientConfig = {
|
|
|
508
508
|
root: `${paths.appSrc}/styles/`
|
|
509
509
|
}
|
|
510
510
|
],
|
|
511
|
+
'tailwindcss/nesting',
|
|
512
|
+
'tailwindcss',
|
|
511
513
|
[
|
|
512
514
|
'postcss-preset-env',
|
|
513
515
|
{
|
|
@@ -516,7 +518,6 @@ const clientConfig = {
|
|
|
516
518
|
browsers: pkg.browserslist,
|
|
517
519
|
}
|
|
518
520
|
],
|
|
519
|
-
'tailwindcss',
|
|
520
521
|
'postcss-modules-values',
|
|
521
522
|
'postcss-flexbugs-fixes',
|
|
522
523
|
],
|
|
@@ -525,37 +526,50 @@ const clientConfig = {
|
|
|
525
526
|
},
|
|
526
527
|
],
|
|
527
528
|
},
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
529
|
+
{
|
|
530
|
+
test: /\.less$/,
|
|
531
|
+
use: [
|
|
532
|
+
MiniCssExtractPlugin.loader,
|
|
533
|
+
...styleLoaders({ isClient: true }).filter(
|
|
534
|
+
(loader) => loader.loader !== 'less-loader'
|
|
535
|
+
),
|
|
536
|
+
{
|
|
537
|
+
loader: 'less-loader',
|
|
538
|
+
options: {
|
|
539
|
+
lessOptions: {
|
|
540
|
+
javascriptEnabled: true,
|
|
541
|
+
paths: [`${paths.appSrc}/styles`],
|
|
542
|
+
},
|
|
543
|
+
},
|
|
544
|
+
},
|
|
545
|
+
],
|
|
546
|
+
}
|
|
547
|
+
]
|
|
548
|
+
},
|
|
549
|
+
plugins: [
|
|
550
|
+
...baseClientConfig.plugins,
|
|
551
|
+
new StyleLintPlugin({
|
|
552
|
+
configFile: `${paths.appPath}/.stylelintrc.json`,
|
|
553
|
+
extensions: ['less'],
|
|
554
|
+
exclude: ['node_modules', 'coverage'],
|
|
555
|
+
}),
|
|
556
|
+
new webpack.HotModuleReplacementPlugin(),
|
|
557
|
+
new SubresourceIntegrityPlugin(),
|
|
558
|
+
new LoadablePlugin({
|
|
559
|
+
writeToDisk: {
|
|
560
|
+
filename: paths.appBuild
|
|
561
|
+
},
|
|
562
|
+
outputAsset: false
|
|
563
|
+
}),
|
|
564
|
+
// Define free variables
|
|
565
|
+
// https://webpack.github.io/docs/list-of-plugins.html#defineplugin
|
|
566
|
+
new webpack.DefinePlugin({
|
|
567
|
+
CONFIG: JSON.stringify(config.globals),
|
|
568
|
+
'process.env.DEV_SERVER': isRuntimeDev,
|
|
569
|
+
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
|
|
570
|
+
'process.env.BROWSER': true,
|
|
571
|
+
__DEVTOOLS__: isVerbose // <-------- DISABLE redux-devtools HERE
|
|
572
|
+
}),
|
|
559
573
|
|
|
560
574
|
new MiniCssExtractPlugin({
|
|
561
575
|
// Options similar to the same options in webpackOptions.output
|
|
@@ -662,76 +676,83 @@ const clientConfig = {
|
|
|
662
676
|
devtool: isDevEnv && useSourceMap ? 'eval' : false,
|
|
663
677
|
};
|
|
664
678
|
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
}
|
|
679
|
+
//
|
|
680
|
+
// Configuration for the server-side bundle (server.js)
|
|
681
|
+
// -----------------------------------------------------------------------------
|
|
682
|
+
const baseServerConfig = webpackConfig({ isClient: false });
|
|
683
|
+
const serverConfig = {
|
|
684
|
+
...baseServerConfig,
|
|
685
|
+
name: 'server',
|
|
686
|
+
target: 'node',
|
|
687
|
+
devtool: isDevEnv && useSourceMap ? 'eval' : false,
|
|
688
|
+
performance: false,
|
|
689
|
+
optimization: {
|
|
690
|
+
nodeEnv: false,
|
|
691
|
+
splitChunks: {
|
|
692
|
+
name: false,
|
|
693
|
+
cacheGroups: {
|
|
694
|
+
vendor: {
|
|
695
|
+
test: /[\\/]node_modules[\\/]/,
|
|
696
|
+
chunks: 'all',
|
|
697
|
+
enforce: true
|
|
685
698
|
}
|
|
686
|
-
}
|
|
687
|
-
minimize: isProdEnv,
|
|
688
|
-
minimizer: [
|
|
689
|
-
new TerserPlugin(),
|
|
690
|
-
new CssMinimizerPlugin()
|
|
691
|
-
]
|
|
692
|
-
},
|
|
693
|
-
entry: {
|
|
694
|
-
server: [
|
|
695
|
-
path.resolve(__dirname, './utils/polyfills.js'),
|
|
696
|
-
`${paths.appSrc}/server.js`
|
|
697
|
-
]
|
|
698
|
-
},
|
|
699
|
-
output: {
|
|
700
|
-
...baseServerConfig.output,
|
|
701
|
-
path: paths.appBuild,
|
|
702
|
-
filename: '[name].js',
|
|
703
|
-
libraryTarget: 'commonjs2',
|
|
704
|
-
},
|
|
705
|
-
module: {
|
|
706
|
-
...baseServerConfig.module,
|
|
707
|
-
rules: [
|
|
708
|
-
...baseServerConfig.module.rules,
|
|
709
|
-
{
|
|
710
|
-
test: /\.css$/,
|
|
711
|
-
use: styleLoaders({ isClient: false }),
|
|
712
|
-
},
|
|
713
|
-
],
|
|
699
|
+
}
|
|
714
700
|
},
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
701
|
+
minimize: isProdEnv,
|
|
702
|
+
minimizer: [
|
|
703
|
+
new TerserPlugin(),
|
|
704
|
+
new CssMinimizerPlugin()
|
|
705
|
+
]
|
|
706
|
+
},
|
|
707
|
+
entry: {
|
|
708
|
+
server: [
|
|
709
|
+
path.resolve(__dirname, './utils/polyfills.js'),
|
|
710
|
+
`${paths.appSrc}/server.js`
|
|
711
|
+
]
|
|
712
|
+
},
|
|
713
|
+
output: {
|
|
714
|
+
...baseServerConfig.output,
|
|
715
|
+
path: paths.appBuild,
|
|
716
|
+
filename: '[name].js',
|
|
717
|
+
libraryTarget: 'commonjs2',
|
|
718
|
+
},
|
|
719
|
+
module: {
|
|
720
|
+
...baseServerConfig.module,
|
|
721
|
+
rules: [
|
|
722
|
+
...baseServerConfig.module.rules,
|
|
723
|
+
{
|
|
724
|
+
test: /\.css$/,
|
|
725
|
+
use: styleLoaders({ isClient: false }).filter(
|
|
726
|
+
(loader) => loader.loader !== 'less-loader'
|
|
727
|
+
),
|
|
728
|
+
},
|
|
729
|
+
{
|
|
730
|
+
test: /\.less$/,
|
|
731
|
+
use: styleLoaders({ isClient: false }),
|
|
732
|
+
},
|
|
721
733
|
],
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
734
|
+
},
|
|
735
|
+
externalsPresets: { node: true },
|
|
736
|
+
externals: [
|
|
737
|
+
nodeExternals({
|
|
738
|
+
allowlist: [/^driver\.js/],
|
|
739
|
+
}),
|
|
740
|
+
/^\.\/assets\.json$/,
|
|
741
|
+
],
|
|
742
|
+
plugins: [
|
|
743
|
+
...baseServerConfig.plugins,
|
|
744
|
+
// Define free variables
|
|
745
|
+
// https://webpack.github.io/docs/list-of-plugins.html#defineplugin
|
|
746
|
+
new webpack.DefinePlugin({
|
|
747
|
+
CONFIG: JSON.stringify(config.globals),
|
|
748
|
+
'process.env.DEV_SERVER': isRuntimeDev,
|
|
749
|
+
'process.env.BROWSER': false,
|
|
750
|
+
__DEVTOOLS__: false // <-------- DISABLE redux-devtools HERE
|
|
751
|
+
}),
|
|
752
|
+
// Do not create separate chunks of the server bundle
|
|
753
|
+
// https://webpack.github.io/docs/list-of-plugins.html#limitchunkcountplugin
|
|
754
|
+
new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1 })
|
|
755
|
+
].filter(Boolean),
|
|
735
756
|
|
|
736
757
|
node: {
|
|
737
758
|
global: false,
|
|
@@ -742,5 +763,4 @@ const clientConfig = {
|
|
|
742
763
|
|
|
743
764
|
let configs = smp.wrap([clientConfig, serverConfig]);
|
|
744
765
|
|
|
745
|
-
|
|
746
|
-
};
|
|
766
|
+
module.exports = configs;
|