Skip to content

Commit 9b3930d

Browse files
authored
Vite migration (#410)
Based on gridsuite/gridstudy-app#1919 and the latest changes on gridstudy to homogenize the code base. Signed-off-by: Florent MILLOT <[email protected]>
1 parent 335ef07 commit 9b3930d

Some content is hidden

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

61 files changed

+8063
-12429
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: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
REACT_APP_API_GATEWAY=api/gateway
2-
REACT_APP_WS_GATEWAY=ws/gateway
3-
EXTEND_ESLINT=true
1+
VITE_API_GATEWAY=api/gateway
2+
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
@@ -36,8 +36,9 @@ jobs:
3636
run: |
3737
npm install
3838
npm run licenses-check
39-
npm run-script build
40-
npm run-script test
39+
npm run lint
40+
npm run test
41+
npm run build
4142
4243
- name: Build and publish Docker image - Main
4344
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/gridexplore
6-
RUN sed -i -e 's;<base href="\./"/>;<base href="<!--#echo var="BASE" -->"/>;' /opt/bitnami/apache/htdocs/gridexplore/index.html
6+
RUN sed -i -e 's;<base href="/" />;<base href="<!--#echo var="BASE" -->" />;' /opt/bitnami/apache/htdocs/gridexplore/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 class="singlestretch-parent" 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>GridExplore</title>
1616
</head>
1717
<body class="singlestretch-parent singlestretch-child">
1818
<noscript>You need to enable JavaScript to run this app.</noscript>
1919
<div id="root" class="singlestretch-parent singlestretch-child"></div>
20+
<script type="module" src="/src/index.jsx"></script>
2021
</body>
2122
</html>

jest.config.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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$': '<rootDir>/src/_mocks_/svg.tsx',
14+
'^.+\\.(css|less|scss)$': 'identity-obj-proxy',
15+
},
16+
transformIgnorePatterns: [
17+
'node_modules/(?!@gridsuite/commons-ui|react-dnd|dnd-core|@react-dnd)',
18+
], // transform from ESM
19+
moduleDirectories: ['node_modules', 'src'], // to allow absolute path from ./src
20+
globals: {
21+
IS_REACT_ACT_ENVIRONMENT: true,
22+
},
23+
setupFiles: ['<rootDir>/jest.setup.ts'],
24+
};
25+
26+
export default config;

jest.setup.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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+
import fetch from './src/_mocks_/fetch';
10+
11+
// fix for ReferenceError: (.*) is not defined
12+
Object.assign(global, { TextDecoder, TextEncoder, fetch });

0 commit comments

Comments
 (0)