Skip to content

Commit e5bccbb

Browse files
authored
Move from create-react-app to parcel (#3041)
- Eject CRA and use Parceljs for building the frontend - Also update to the latest: babel, eslint, jest, typescript Cuts frontend / docker_build time from ~2:20 to ~1:20, but frontend / test_coverage time is still ~3:20.
1 parent b812dde commit e5bccbb

File tree

32 files changed

+8127
-15233
lines changed

32 files changed

+8127
-15233
lines changed

.dockerignore

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22
**
33

44
# Except the following.
5+
!.env
6+
!.parcelrc
7+
!dev-requirements.txt
58
!docs/user_guide
9+
!eslint.config.mjs
610
!nginx
11+
!package*.json
712
!public
8-
!scripts/touchPublicScripts.js
13+
!scripts/parcelResolver.js
914
!src
10-
!.env
11-
!.eslintrc.cjs
12-
!dev-requirements.txt
13-
!package*.json
1415
!tox.ini
1516
!tsconfig.json
1617

.eslintrc.cjs

Lines changed: 0 additions & 69 deletions
This file was deleted.

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,17 @@
1111

1212
# Production
1313
build
14+
/dist
1415

1516
# Generated files for development use
1617
docker-compose.yml
1718
.env.*
1819
!.env.development
1920
.env*.local
21+
.parcel-cache
2022
nginx/scripts
2123
/backups
24+
/parcel-bundle-reports
2225
/restore
2326
script_conf.json
2427
backup_conf.json
@@ -29,9 +32,6 @@ public/scripts/
2932
.eslintcache
3033
Session.vim
3134
scripts/*.js
32-
!scripts/createBackendLicenses.js
33-
!scripts/printVersion.js
34-
!scripts/setRelease.js
3535
*.log
3636
*-debug.log*
3737
*-error.log*

.parcelrc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"extends": [
3+
"@parcel/config-default"
4+
],
5+
"reporters": [
6+
"...",
7+
"parcel-reporter-static-files-copy"
8+
],
9+
"resolvers": [
10+
"./scripts/parcelResolver.js",
11+
"..."
12+
]
13+
}

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"type": "chrome",
1616
"request": "launch",
1717
"name": "Launch Chrome against localhost",
18-
"url": "http://localhost:3000",
18+
"url": "http://localhost:1234",
1919
"webRoot": "${workspaceFolder}"
2020
},
2121
{

.vscode/settings.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@
3232
},
3333
"files.insertFinalNewline": true,
3434
"cSpell.ignorePaths": [
35-
"*.dic.js",
35+
"dist",
3636
"docs/user_guide/docs/*.*.md",
3737
"node_modules",
3838
"package-lock.json",
39-
"public/locales/",
40-
"!public/locales/en/"
39+
"public/dictionaries",
40+
"public/locales",
41+
"!public/locales/en"
4142
],
4243
"cSpell.words": [
4344
"Adposition",

Backend/Helper/Domain.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ public static class Domain
88
Environment.GetEnvironmentVariable("COMBINE_FRONTEND_SERVER_NAME");
99

1010
public static readonly string FrontendDomain =
11-
string.IsNullOrEmpty(_frontendServer) ? "http://localhost:3000" : $"https://{_frontendServer}";
11+
string.IsNullOrEmpty(_frontendServer) ? "http://localhost:1234" : $"https://{_frontendServer}";
1212
}
1313
}

Backend/Startup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public void ConfigureServices(IServiceCollection services)
114114
.AllowAnyHeader()
115115
.AllowAnyMethod()
116116
// Add URL for React CLI using during development.
117-
.WithOrigins("http://localhost:3000")
117+
.WithOrigins("http://localhost:1234")
118118
.AllowCredentials());
119119
});
120120
}

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ RUN mkdir ${FRONTEND_HOST_DIR}/url_moved
5151

5252
# Setup web content
5353
COPY --from=user_guide_builder /app/docs/user_guide/site ${HOST_DIR}/user_guide
54-
COPY --from=frontend_builder /app/build ${FRONTEND_HOST_DIR}
54+
COPY --from=frontend_builder /app/dist ${FRONTEND_HOST_DIR}
5555
COPY public/dictionaries ${HOST_DIR}/dictionaries
56+
COPY public/locales ${FRONTEND_HOST_DIR}/locales
5657
COPY nginx/pages/url_moved_home.html /etc/nginx/page_templates/url_moved_home.html
5758
COPY public/favicon.ico ${FRONTEND_HOST_DIR}/url_moved/favicon.ico
5859
COPY src/resources/tractor.png ${FRONTEND_HOST_DIR}/url_moved/tractor.png

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
[localization-ui-badge]: https://img.shields.io/badge/User%20Interface-Ar%20En%20Es%20Fr%20Pt%20Zh-blue
2323
[github-actions-frontend]: https://github.com/sillsdev/TheCombine/actions/workflows/frontend.yml
2424
[github-actions-backend]: https://github.com/sillsdev/TheCombine/actions/workflows/backend.yml
25-
[localization-sd-badge]:
26-
https://img.shields.io/badge/Semantic%20Domains-Ar%20En%20Es%20Fr%20Hi%20Id%20Ml%20My%20Pt%20Ru%20Sw%20Zh-blue
25+
[localization-sd-badge]: https://img.shields.io/badge/Semantic%20Domains-Ar%20En%20Es%20Fr%20Hi%20Id%20Ml%20My%20Pt%20Ru%20Sw%20Zh-blue
2726
[localization-ug-badge]: https://img.shields.io/badge/User%20Guide-En%20Es%20Zh-blue
2827
[localization-crowdin-combine]: https://crowdin.com/project/the-combine
2928
[localization-crowdin-flex]: https://crowdin.com/project/fieldworks
@@ -278,7 +277,7 @@ In the project directory, you can run:
278277
279278
Installs the necessary packages and runs the app in the development mode.
280279

281-
Open <http://localhost:3000> to view it in the browser.
280+
Open <http://localhost:1234> to view it in the browser.
282281

283282
#### `npm run frontend`
284283

@@ -294,7 +293,7 @@ Runs only the mongo database.
294293

295294
#### `npm run build`
296295

297-
Builds the app for production to the `build` folder.
296+
Builds the app for production to the `dist` folder.
298297

299298
It correctly bundles React in production mode and optimizes the build for the best performance.
300299

@@ -304,9 +303,9 @@ Your app is ready to be deployed!
304303

305304
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
306305

307-
#### `npm run analyze`
306+
#### `npm run build:analyze`
308307

309-
Run after `npm run build` to analyze the contents build bundle chunks.
308+
Builds then generates a tree map of the bundle chunks.
310309

311310
### Using OpenAPI
312311

@@ -1175,6 +1174,7 @@ The process for configuring and deploying _TheCombine_ for production targets is
11751174
- [React-i18next](https://react.i18next.com/) (text localization)
11761175
- [Jest](https://jestjs.io/docs/getting-started) (unit testing)
11771176
- [React Testing Library](https://testing-library.com/docs/react-testing-library/intro) (unit testing)
1177+
- [Parcel](https://parceljs.org/docs/) (bundler/builder)
11781178

11791179
### Kubernetes/Helm
11801180

0 commit comments

Comments
 (0)