Skip to content
This repository was archived by the owner on Apr 24, 2024. It is now read-only.

Commit 9d8cfe8

Browse files
tavikukkoTomi TavelaNargonath
authored
feat: add support for create-react-app@4 (#249)
* fixed issues related to CRA 4 Just fixed issues when using with CRA 4, but there might be some breaking changes that need attention too. * disabled fast-refresh * updated dependencies * deleted package.lock and used yarn to upgrade deps * Revert "deleted package.lock and used yarn to upgrade deps" This reverts commit 35ae92c. * Revert "updated dependencies" This reverts commit b0260f1. * docs: update readme to reflect cra@4 support Co-authored-by: Tomi Tavela <[email protected]> Co-authored-by: Nargonath <[email protected]>
1 parent 347e090 commit 9d8cfe8

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ As of now (20/04/2018), `create-react-app` (more precisely `react-scripts`) does
3737

3838
# Prerequisites
3939

40-
Supports `react-scripts >= 1.0.x`, hence it supports the newest version `3.x.x`.
40+
Supports `react-scripts >= 1.0.x`, hence it supports the newest version `4.x.x`.
4141

4242
Supports `node >= 10`.
4343

scripts/index.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
process.env.NODE_ENV = 'development'; // eslint-disable-line no-process-env
4+
process.env.FAST_REFRESH = false;
45

56
const importCwd = require('import-cwd');
67
const fs = require('fs-extra');
@@ -52,7 +53,9 @@ const env = getClientEnvironment(process.env.PUBLIC_URL || ''); // eslint-disabl
5253
/**
5354
* We need to update the webpack dev config in order to remove the use of webpack devserver
5455
*/
55-
config.entry = config.entry.filter(fileName => !fileName.match(/webpackHotDevClient/));
56+
if (major < 4) {
57+
config.entry = config.entry.filter(fileName => !fileName.match(/webpackHotDevClient/));
58+
}
5659
config.plugins = config.plugins.filter(
5760
plugin => !(plugin instanceof webpack.HotModuleReplacementPlugin)
5861
);
@@ -87,7 +90,13 @@ if (disableChunks) {
8790
}
8891

8992
// update media path destination
90-
if (major >= 2) {
93+
if (major >= 4) {
94+
const oneOfIndex = 1
95+
config.module.rules[oneOfIndex].oneOf[0].options.name = `media/[name].[hash:8].[ext]`;
96+
config.module.rules[oneOfIndex].oneOf[1].options.name = `media/[name].[hash:8].[ext]`;
97+
config.module.rules[oneOfIndex].oneOf[8].options.name = `media/[name].[hash:8].[ext]`;
98+
}
99+
else if (major >= 2) {
91100
// 2.0.0 => 2
92101
// 2.0.1 => 3
93102
// 2.0.2 => 3

0 commit comments

Comments
 (0)