Skip to content

Commit

Permalink
build(vite): replace create-react-app by Vite (#1905)
Browse files Browse the repository at this point in the history
* update ESLint rules and fix lint issues
* remove obsolete packages
* update Handsontable to fix import issue
* update bash script for build
* update GitHub workflow
* create fnUtils

ANT-1060
  • Loading branch information
skamril committed Jan 25, 2024
1 parent 4ef1f38 commit b4e3fd8
Show file tree
Hide file tree
Showing 180 changed files with 7,500 additions and 19,873 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm install --legacy-peer-deps
run: npm install
working-directory: webapp
- name: Build
run: npm run build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
node-version: 18.16.1

- name: 💚 Install dependencies
run: npm install --legacy-peer-deps
run: npm install
working-directory: webapp

- name: 💚 Build webapp
Expand Down
17 changes: 1 addition & 16 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
with:
node-version: 18.16.1
- name: Install dependencies
run: npm install --legacy-peer-deps
run: npm install
working-directory: webapp
- name: Build
run: npm run build
Expand All @@ -89,16 +89,6 @@ jobs:
- name: Lint
run: npm run lint
working-directory: webapp
- name: Run tests
run: npm run test-coverage
working-directory: webapp
env:
CI: true
- name: Archive code coverage results
uses: actions/upload-artifact@v3
with:
name: js-code-coverage-report
path: webapp/coverage/lcov.info

sonarcloud:
runs-on: ubuntu-20.04
Expand All @@ -109,11 +99,6 @@ jobs:
uses: actions/download-artifact@v3
with:
name: python-code-coverage-report
- name: Download js coverage report
uses: actions/download-artifact@v3
with:
name: js-code-coverage-report
path: webapp/coverage
- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@master
env:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Install the front-end dependencies:

```shell script
cd webapp
npm install --legacy-peer-deps
npm install
cd ..
```

Expand Down
2 changes: 1 addition & 1 deletion docs/install/0-INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Then perform the following steps:

```shell
cd webapp
npm install --legacy-peer-deps
npm install
npm run build
cd ..
```
Expand Down
26 changes: 3 additions & 23 deletions scripts/build-front.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,8 @@ set -e
CURR_DIR=$(cd "$(dirname "$0")" && pwd)

cd "$CURR_DIR"/../webapp

# shellcheck disable=SC2016
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' 's|"homepage".*|"homepage": "/static",|g' package.json
sed -i '' 's|loadPath.*|loadPath: `/static/locales/{{lng}}/{{ns}}.json?v=${version}`,|g' src/i18n.js
else
sed -i 's|"homepage".*|"homepage": "/static",|g' package.json
sed -i 's|loadPath.*|loadPath: `/static/locales/{{lng}}/{{ns}}.json?v=${version}`,|g' src/i18n.js
fi

./node_modules/.bin/cross-env GENERATE_SOURCEMAP=false DISABLE_ESLINT_PLUGIN=true npm run build

# shellcheck disable=SC2016
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' 's|"homepage".*|"homepage": "/",|g' package.json
sed -i '' 's|loadPath.*|loadPath: `/locales/{{lng}}/{{ns}}.json?v=${version}`,|g' src/i18n.js
else
sed -i 's|"homepage".*|"homepage": "/",|g' package.json
sed -i 's|loadPath.*|loadPath: `/locales/{{lng}}/{{ns}}.json?v=${version}`,|g' src/i18n.js
fi

npm run build
cd ..
rm -fr resources/webapp
cp -r ./webapp/build/ resources/webapp
cp ./webapp/build/index.html resources/templates/
cp -r ./webapp/dist/ resources/webapp
cp ./webapp/dist/index.html resources/templates/
70 changes: 70 additions & 0 deletions webapp/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
module.exports = {
root: true,
env: {
browser: true,
es2022: true,
},
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended", // TODO: replace with recommended-type-checked
"plugin:@typescript-eslint/stylistic", // TODO: replace with stylistic-type-checked
"plugin:react/recommended",
"plugin:react/jsx-runtime",
"plugin:react-hooks/recommended",
"plugin:prettier/recommended",
],
plugins: ["react-refresh"],
ignorePatterns: ["dist", ".eslintrc.cjs"],
parser: "@typescript-eslint/parser",
parserOptions: {
sourceType: "module",
project: ["./tsconfig.json", "./tsconfig.node.json"],
tsconfigRootDir: __dirname,
},
settings: {
react: {
version: "detect",
},
},
rules: {
"@typescript-eslint/array-type": ["error", { default: "array-simple" }],
"@typescript-eslint/no-unused-vars": [
"error",
{ args: "none", ignoreRestSiblings: true },
],
camelcase: [
"error",
{
properties: "never", // TODO: remove when server responses are camel case
allow: [
"MRT_", // For material-react-table
],
},
],
"no-param-reassign": [
"error",
{
props: true,
ignorePropertyModificationsForRegex: [
// For immer, 'acc' for
"^draft",
// For `Array.prototype.reduce()`
"acc",
"accumulator",
],
},
],
"no-use-before-define": [
"error",
{
// Function declarations are hoisted, so it’s safe.
functions: false,
},
],
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
"react/prop-types": "off",
},
};
101 changes: 0 additions & 101 deletions webapp/.eslintrc.json

This file was deleted.

41 changes: 19 additions & 22 deletions webapp/.gitignore
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage
# Logs
logs
*.log
npm-debug.log*

# production
/build
node_modules
dist
dist-ssr
*.local

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

# workspace
# Editor directories and files
.vscode/*
!.vscode/extensions.json
*.code-workspace
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
.env.*

npm-debug.log*
yarn-debug.log*
yarn-error.log*
Empty file removed webapp/.prettierignore
Empty file.
60 changes: 22 additions & 38 deletions webapp/README.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,30 @@
# Getting Started with Create React App
# React + TypeScript + Vite

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

## Available Scripts
Currently, two official plugins are available:

In the project directory, you can run:
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

### `npm start`
## Expanding the ESLint configuration

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:

The page will reload if you make edits.\
You will also see any lint errors in the console.
- Configure the top-level `parserOptions` property like this:

### `npm test`
```js
export default {
// other rules...
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
project: ["./tsconfig.json", "./tsconfig.node.json"],
tsconfigRootDir: __dirname,
},
};
```

Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### `npm run build`

Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!

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

### `npm run eject`

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**

If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).
- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list
Loading

0 comments on commit b4e3fd8

Please sign in to comment.