Skip to content

Commit d0c94e4

Browse files
Merge pull request #291 from hyva-themes/289/react-18
Upgrade to React 18
2 parents f753873 + e545543 commit d0c94e4

File tree

104 files changed

+4828
-7640
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+4828
-7640
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
.DS_Store
2+
.idea

src/reactapp/config-overrides.js

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1+
/* eslint-disable import/no-extraneous-dependencies */
2+
const LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
3+
4+
const cssFileNameUpdator = require('./scripts/react-app-rewire/css-file-name-updator');
5+
const reactAppRewirePostCssApplier = require('./scripts/react-app-rewire/postcss-applier');
6+
17
module.exports = function override(config, env) {
2-
const isEnvDevelopment = env === 'development';
38
const isEnvProduction = env === 'production';
49
const filename = isEnvProduction
510
? '../../view/frontend/web/js/react-checkout.js'
6-
: isEnvDevelopment && 'static/js/bundle.js';
11+
: 'static/js/bundle.js';
712
const chunkFilename = isEnvProduction
813
? '../../view/frontend/web/js/[name].chunk.js'
9-
: isEnvDevelopment && 'static/js/[name].chunk.js';
14+
: 'static/js/[name].chunk.js';
1015

11-
const baseConfig = {
16+
const newConfig = {
1217
...config,
13-
output: {
14-
...config.output,
15-
filename,
16-
chunkFilename,
17-
},
1818
optimization: {
1919
...config.optimization,
2020
runtimeChunk: false,
@@ -24,15 +24,29 @@ module.exports = function override(config, env) {
2424
name: false,
2525
},
2626
},
27+
output: {
28+
...config.output,
29+
filename,
30+
chunkFilename,
31+
},
2732
};
2833

2934
if (isEnvProduction) {
30-
baseConfig.resolve.alias = {
31-
...baseConfig.resolve.alias,
35+
newConfig.plugins = [
36+
...newConfig.plugins,
37+
new LodashModuleReplacementPlugin({ paths: true }),
38+
];
39+
newConfig.resolve.alias = {
40+
...newConfig.resolve.alias,
41+
lodash: 'lodash-es',
3242
react: 'preact/compat',
3343
'react-dom': 'preact/compat',
3444
};
3545
}
46+
// Save css bundle into styles.css
47+
cssFileNameUpdator(newConfig, isEnvProduction);
48+
// Apply postcss.config.js
49+
reactAppRewirePostCssApplier(newConfig);
3650

37-
return baseConfig;
51+
return newConfig;
3852
};

0 commit comments

Comments
 (0)