Skip to content

Commit d56ce77

Browse files
authored
Vite migration (#30)
Based on the latest changes on gridstudy to homogenize the code base. Signed-off-by: Florent MILLOT <[email protected]>
1 parent 12dbe9f commit d56ce77

25 files changed

+9602
-14852
lines changed

.browserslistrc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Browsers that we support
2+
3+
[production]
4+
>0.2% and supports es6-class
5+
not dead
6+
not op_mini all
7+
not chrome < 51
8+
not safari < 10
9+
10+
[development]
11+
last 1 chrome version
12+
last 1 firefox version
13+
last 1 safari version

.env

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
EXTEND_ESLINT=true
2-
REACT_APP_DEBUG_REQUESTS=false
3-
REACT_APP_DEBUG_AGGRID=false
1+
VITE_DEBUG_REQUESTS=false
2+
VITE_DEBUG_AGGRID=false
43

5-
REACT_APP_API_GATEWAY=/api/gateway
6-
REACT_APP_WS_GATEWAY=/ws/gateway
4+
VITE_API_GATEWAY=/api/gateway
5+
VITE_WS_GATEWAY=/ws/gateway

.eslintrc.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"root": true,
3+
"extends": [
4+
"react-app",
5+
"plugin:prettier/recommended"
6+
],
7+
"ignorePatterns": [
8+
// node_modules is implicitly always ignored
9+
"build"
10+
],
11+
"rules": {
12+
"prettier/prettier": "warn",
13+
"curly": "error"
14+
}
15+
}

.github/workflows/build.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ jobs:
1919
- name: Install and Build
2020
run: |
2121
npm install
22-
npm run-script build
23-
npm run-script test
22+
npm run lint
23+
npm run test
24+
npm run build
2425
2526
- name: Build and publish Docker image - Main
2627
if: github.ref == 'refs/heads/main'

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
# webstorm
88
/.idea
99

10+
# vscode
11+
/.vscode
12+
1013
# misc
1114
.env.local
1215
.env.development.local

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ FROM bitnami/apache:2.4.55-debian-11-r3@sha256:bbe50190eb3bbf3be6f61318004480b32
33
USER root
44
COPY app-httpd.conf /opt/bitnami/apache/conf/bitnami/bitnami.conf
55
COPY build /opt/bitnami/apache/htdocs/gridadmin
6-
RUN sed -i -e 's;<base href="\./"/>;<base href="<!--#echo var="BASE" -->"/>;' /opt/bitnami/apache/htdocs/gridadmin/index.html
6+
RUN sed -i -e 's;<base href="/" />;<base href="<!--#echo var="BASE" -->" />;' /opt/bitnami/apache/htdocs/gridadmin/index.html
77
USER 1001

babel.config.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"presets": [
3+
"@babel/preset-env",
4+
["@babel/preset-react", { "runtime": "automatic" }],
5+
"@babel/preset-typescript",
6+
"babel-preset-vite"
7+
]
8+
}

public/index.html renamed to index.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@
77
<!DOCTYPE html>
88
<html lang="en" translate="no">
99
<head>
10-
<base href="%PUBLIC_URL%/" />
10+
<base href="/" />
1111
<meta charset="utf-8" />
1212
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
1313
<meta name="google" content="notranslate" />
14-
<link rel="icon" href="favicon.ico" />
14+
<link rel="icon" href="/favicon.ico" />
1515
<title>GridAdminApp</title>
1616
</head>
1717
<body>
1818
<noscript>You need to enable JavaScript to run this app.</noscript>
1919
<div id="root"></div>
20+
<script type="module" src="/src/index.tsx"></script>
2021
</body>
2122
</html>

jest.config.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* Copyright (c) 2024, RTE (http://www.rte-france.com)
3+
* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
*/
7+
8+
import type { Config } from 'jest';
9+
10+
const config: Config = {
11+
testEnvironment: 'jsdom',
12+
moduleNameMapper: {
13+
'^.+\\.svg\\?react$': 'jest-svg-transformer',
14+
'^.+\\.(css|less|scss)$': 'identity-obj-proxy',
15+
},
16+
// if need to test with AG Grid, see https://www.ag-grid.com/react-data-grid/testing/
17+
transformIgnorePatterns: ['node_modules/(?!@gridsuite/commons-ui)'], // transform from ESM
18+
moduleDirectories: ['node_modules', 'src'], // to allow absolute path from ./src
19+
setupFiles: ['<rootDir>/jest.setup.ts'],
20+
};
21+
22+
export default config;

jest.setup.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* Copyright (c) 2024, RTE (http://www.rte-france.com)
3+
* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
*/
7+
8+
import { TextEncoder, TextDecoder } from 'util';
9+
10+
// fix for ReferenceError: TextDecoder / TextEncoder is not defined
11+
Object.assign(global, { TextDecoder, TextEncoder });

0 commit comments

Comments
 (0)