Skip to content

Commit aff2eec

Browse files
Remove react-scripts (#937)
1 parent 513f13d commit aff2eec

File tree

6 files changed

+33
-12
lines changed

6 files changed

+33
-12
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,10 @@ jobs:
7474
path: |
7575
${{ env.yarn_cache }}
7676
admin-js/node_modules
77+
admin-js/yarn.lock
7778
- name: Yarn install
7879
if: steps.cache_node_modules.outputs.cache-hit != 'true'
79-
run: yarn install
80+
run: yarn install --production
8081
working-directory: admin-js/
8182
- name: Cache output files
8283
uses: actions/cache@v4
@@ -85,10 +86,10 @@ jobs:
8586
key: yarn-${{ hashFiles('admin-js/src/*') }}-${{ hashFiles('admin-js/yarn.lock') }}
8687
path: |
8788
aiohttp_admin/static/admin.js
88-
aiohttp_admin/static/*.map
89+
aiohttp_admin/static/admin.js.map
8990
- name: Yarn build
9091
if: steps.cache_admin_js.outputs.cache-hit != 'true'
91-
run: yarn build
92+
run: yarn build --minify false
9293
working-directory: admin-js/
9394

9495
test:
@@ -235,10 +236,10 @@ jobs:
235236
- name: Install yarn
236237
run: sudo apt install yarn -y
237238
- name: Yarn install
238-
run: yarn install
239+
run: yarn install --production
239240
working-directory: admin-js/
240241
- name: Yarn build
241-
run: yarn build
242+
run: yarn build --production
242243
working-directory: admin-js/
243244
- name: Install dependencies
244245
run:

admin-js/package.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
"react": "18.2.0",
77
"react-admin": "4.16.7",
88
"react-dom": "18.2.0",
9+
"terser": "5.40.0",
10+
"vite": "6.2.6",
911

1012
"create-react-admin": "4.16.7",
1113
"ra-core": "4.16.7",
@@ -25,19 +27,22 @@
2527
"ra-ui-materialui": "4.16.7"
2628
},
2729
"devDependencies": {
30+
"@babel/preset-env": "7.27.2",
31+
"@babel/preset-react": "7.27.1",
2832
"@testing-library/dom": "10.4.0",
2933
"@testing-library/jest-dom": "6.6.3",
3034
"@testing-library/react": "16.3.0",
3135
"@testing-library/user-event": "14.6.1",
3236
"@ungap/structured-clone": "1.3.0",
37+
"jest": "29.7.0",
38+
"jest-environment-jsdom": "29.7.0",
3339
"jest-fail-on-console": "3.3.1",
34-
"react-scripts": "5.0.1"
40+
"whatwg-fetch": "3.6.20"
3541
},
3642
"scripts": {
37-
"start": "react-scripts start",
38-
"build": "react-scripts build && (rm ../aiohttp_admin/static/*.js.map || true) && mv build/static/js/main.*.js ../aiohttp_admin/static/admin.js && mv build/static/js/main.*.js.map ../aiohttp_admin/static/ && rm -rf build/",
39-
"test": "jest",
40-
"eject": "react-scripts eject"
43+
"dev": "vite",
44+
"build": "vite build",
45+
"test": "jest"
4146
},
4247
"eslintConfig": {
4348
"extends": [

admin-js/public/index.html

Whitespace-only changes.

admin-js/src/App.js renamed to admin-js/src/App.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,9 +449,9 @@ const App = (props) => {
449449
STATE = aiohttpState;
450450
const [loaded, setLoaded] = useState(STATE["js_module"] === null);
451451
if (!loaded) {
452-
// The inline comment skips the webpack import() and allows us to use the native
452+
// The inline comment skips the Vite import() and allows us to use the native
453453
// browser's import() function. Needed to dynamically import a module.
454-
import(/* webpackIgnore: true */ STATE["js_module"]).then((mod) => {
454+
import(/* @vite-ignore */ STATE["js_module"]).then((mod) => {
455455
Object.assign(COMPONENTS, mod.components);
456456
Object.assign(FUNCTIONS, mod.functions);
457457
setLoaded(true);
File renamed without changes.

admin-js/vite.config.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { defineConfig } from "vite";
2+
3+
export default defineConfig({
4+
build: {
5+
minify: "terser",
6+
outDir: "../aiohttp_admin/static/",
7+
rollupOptions: {
8+
input: "src/admin.jsx",
9+
output: {
10+
entryFileNames: "[name].js"
11+
}
12+
},
13+
sourcemap: true,
14+
},
15+
})

0 commit comments

Comments
 (0)