Skip to content

Commit d6bea20

Browse files
committed
feat: Replace react-script to vite
1 parent ecd4095 commit d6bea20

File tree

95 files changed

+4064
-8312
lines changed

Some content is hidden

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

95 files changed

+4064
-8312
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"eslint-config-prettier": "9.1.0",
5454
"eslint-plugin-prettier": "4.2.1",
5555
"husky": "8.0.3",
56+
"jest": "29.7.0",
5657
"lerna": "8.1.5",
5758
"lint-staged": "15.2.7",
5859
"ncp": "2.0.0",

packages/neuron-ui/.eslintrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ module.exports = {
6565
'import/no-extraneous-dependencies': [
6666
'error',
6767
{
68-
devDependencies: ['**/*.stories.*', 'src/setupTests.ts', '**/*.test.ts'],
68+
devDependencies: ['**/*.stories.*', 'src/setupTests.ts', '**/*.test.ts', './vitest-setup.js'],
6969
},
7070
],
7171
'import/extensions': [
@@ -96,5 +96,6 @@ module.exports = {
9696
allowExpressions: true,
9797
},
9898
],
99+
'import/no-unresolved': [2, { ignore: ['.svg'] }],
99100
},
100101
}

packages/neuron-ui/.storybook/electron.js

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,17 @@ const sendSyncValues = {
33
'get-version': '0.103.1',
44
}
55

6-
module.exports = {
7-
ipcRenderer: {
8-
sendSync(key) {
9-
return sendSyncValues[key]
10-
},
11-
invoke() {
12-
return Promise.resolve({})
13-
},
14-
on() {},
15-
removeAllListeners() {},
6+
export const ipcRenderer = {
7+
sendSync(key) {
8+
return sendSyncValues[key]
169
},
17-
clipboard() {},
18-
nativeImage() {},
19-
shell() {},
20-
desktopCapturer() {},
10+
invoke() {
11+
return Promise.resolve({})
12+
},
13+
on() {},
14+
removeAllListeners() {},
2115
}
16+
export const clipboard = () => {}
17+
export const nativeImage = () => {}
18+
export const shell = () => {}
19+
export const desktopCapturer = () => {}
Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
1-
export default {
2-
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
1+
import { StorybookConfig } from '@storybook/react-vite'
2+
const { mergeConfig } = require('vite')
3+
import path from 'path'
4+
5+
const config: StorybookConfig = {
6+
stories: ['../src/**/*.stories.@(js|jsx|ts|tsx)'],
37
addons: [
48
'@storybook/addon-links',
59
'@storybook/addon-essentials',
610
'@storybook/addon-interactions',
7-
'@storybook/preset-create-react-app',
811
'storybook-addon-react-router-v6',
912
],
10-
framework: {
11-
name: '@storybook/react-webpack5',
12-
options: {},
13+
framework: '@storybook/react-vite',
14+
core: {
15+
builder: '@storybook/builder-vite',
1316
},
14-
webpackFinal: config => {
15-
config.resolve.fallback = {
16-
fs: false,
17-
crypto: false,
18-
buffer: false,
19-
}
20-
config.resolve.alias = {
21-
...config.resolve.alias,
22-
electron: require.resolve('./electron'),
23-
}
24-
return config
17+
async viteFinal(config) {
18+
return mergeConfig(config, {
19+
resolve: {
20+
alias: { electron: path.resolve(__dirname, '../.storybook/electron') },
21+
},
22+
})
2523
},
2624
docs: {
2725
autodocs: true,
2826
},
27+
staticDirs: ['../public'],
2928
}
29+
30+
export default config

packages/neuron-ui/index.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="utf-8" />
6+
<link rel="shortcut icon" href="/favicon.ico" />
7+
<link rel="stylesheet" href="/css/fonts.css" />
8+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
9+
<meta name="theme-color" content="#000000" />
10+
<title>Neuron</title>
11+
</head>
12+
13+
<body>
14+
<navbar class="navbar"></navbar>
15+
<div id="notification" class="notification"></div>
16+
<main id="root" class="main-content"></main>
17+
<div id="dialog" class="dialog"></div>
18+
<script type="module" src="/src/index.tsx"></script>
19+
</body>
20+
21+
</html>

packages/neuron-ui/package.json

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
"main": "./build",
1616
"license": "MIT",
1717
"scripts": {
18-
"start": "cross-env DISABLE_ESLINT_PLUGIN=true GENERATE_SOURCEMAP=false react-app-rewired start",
18+
"start": "cross-env DISABLE_ESLINT_PLUGIN=true vite",
1919
"lint": "eslint --fix --ext .tsx,.ts,.js src",
20-
"test": "react-app-rewired test --env=jsdom --watchAll=false",
21-
"build": "cross-env DISABLE_ESLINT_PLUGIN=true GENERATE_SOURCEMAP=false react-app-rewired build",
20+
"test": "vitest --environment=jsdom --run --watch=false",
21+
"build": "cross-env DISABLE_ESLINT_PLUGIN=true vite build",
2222
"clean": "npx rimraf build",
2323
"precommit": "lint-staged",
24-
"storybook": "storybook dev -p 9009 -s public",
25-
"build-storybook": "storybook build -s public"
24+
"storybook": "storybook dev -p 9009",
25+
"build-storybook": "storybook build"
2626
},
2727
"publishConfig": {
2828
"registry": "https://registry.npmjs.org/"
@@ -72,24 +72,27 @@
7272
},
7373
"devDependencies": {
7474
"@babel/plugin-proposal-private-property-in-object": "7.21.11",
75+
"@babel/preset-env": "7.26.9",
7576
"@babel/preset-typescript": "7.23.3",
76-
"@jest/globals": "27.5.1",
77-
"@storybook/addon-actions": "7.6.6",
78-
"@storybook/addon-essentials": "7.6.6",
79-
"@storybook/addon-interactions": "7.6.6",
80-
"@storybook/addon-links": "7.6.6",
77+
"@storybook/addon-actions": "8.6.4",
78+
"@storybook/addon-essentials": "8.6.4",
79+
"@storybook/addon-interactions": "8.6.4",
80+
"@storybook/addon-links": "8.6.4",
81+
"@storybook/builder-vite": "8.6.4",
8182
"@storybook/node-logger": "7.6.6",
82-
"@storybook/preset-create-react-app": "7.6.6",
83-
"@storybook/react": "7.6.6",
84-
"@storybook/react-webpack5": "7.6.6",
83+
"@storybook/react": "8.6.4",
84+
"@storybook/react-vite": "8.6.4",
8585
"@storybook/testing-library": "0.2.2",
86+
"@testing-library/jest-dom": "6.6.3",
87+
"@testing-library/react": "16.2.0",
8688
"@types/enzyme": "3.10.18",
8789
"@types/enzyme-adapter-react-16": "1.0.9",
8890
"@types/node": "20.10.5",
8991
"@types/react": "18.2.45",
9092
"@types/react-dom": "18.2.18",
9193
"@types/react-router-dom": "5.3.3",
9294
"@types/styled-components": "5.1.34",
95+
"@vitejs/plugin-react": "4.3.4",
9396
"@wojtekmaj/enzyme-adapter-react-17": "0.8.0",
9497
"babel-jest": "25.5.1",
9598
"electron": "30.0.0",
@@ -100,11 +103,17 @@
100103
"eslint-plugin-jsx-a11y": "6.7.1",
101104
"eslint-plugin-react": "7.32.2",
102105
"jest-styled-components": "7.2.0",
103-
"react-app-rewired": "2.2.1",
104-
"react-scripts": "5.0.1",
106+
"jsdom": "26.0.0",
107+
"postcss-preset-env": "10.1.5",
105108
"react-test-renderer": "18.2.0",
106-
"storybook": "7.6.6",
109+
"storybook": "^8.6.4",
107110
"storybook-addon-react-router-v6": "2.0.10",
111+
"vite": "6.2.1",
112+
"vite-plugin-eslint": "1.8.1",
113+
"vite-plugin-node-polyfills": "0.23.0",
114+
"vite-plugin-require-transform": "1.0.21",
115+
"vite-plugin-svgr": "4.3.0",
116+
"vitest": "3.0.8",
108117
"webpack": "5.94.0"
109118
},
110119
"resolutions": {

packages/neuron-ui/public/index.html

100755100644
Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,21 @@
11
<!DOCTYPE html>
22
<html lang="en">
3-
<head>
4-
<meta charset="utf-8" />
5-
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
6-
<link rel="stylesheet" href="%PUBLIC_URL%/css/fonts.css" />
7-
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
8-
<meta name="theme-color" content="#000000" />
9-
<!--
10-
Notice the use of %PUBLIC_URL% in the tags above.
11-
It will be replaced with the URL of the `public` folder during the build.
12-
Only files inside the `public` folder can be referenced from the HTML.
133

14-
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
15-
work correctly both with client-side routing and a non-root public URL.
16-
Learn how to configure a non-root public URL by running `npm run build`.
17-
-->
18-
<title>Neuron</title>
19-
</head>
4+
<head>
5+
<meta charset="utf-8" />
6+
<link rel="shortcut icon" href="/favicon.ico" />
7+
<link rel="stylesheet" href="/css/fonts.css" />
8+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
9+
<meta name="theme-color" content="#000000" />
10+
<title>Neuron</title>
11+
</head>
2012

21-
<body>
22-
<navbar class="navbar"></navbar>
23-
<div id="notification" class="notification"></div>
24-
<main id="root" class="main-content"></main>
25-
<div id="dialog" class="dialog"></div>
26-
</body>
27-
</html>
13+
<body>
14+
<navbar class="navbar"></navbar>
15+
<div id="notification" class="notification"></div>
16+
<main id="root" class="main-content"></main>
17+
<div id="dialog" class="dialog"></div>
18+
<script type="module" src="/src/index.tsx"></script>
19+
</body>
20+
21+
</html>

packages/neuron-ui/src/components/CompensationPeriodTooltip/index.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import React from 'react'
22
import { useTranslation } from 'react-i18next'
3-
import { getCompensatedTime, getCompensationPeriod, CONSTANTS, CompensationPeriod, uniformTimeFormatter } from 'utils'
3+
import { getCompensatedTime, getCompensationPeriod, CompensationPeriod, uniformTimeFormatter } from 'utils'
4+
import { WITHDRAW_EPOCHS } from 'utils/const'
45
import styles from './compensationPeriodTooltip.module.scss'
56

6-
const { WITHDRAW_EPOCHS } = CONSTANTS
7-
87
const HOUR = 3_600_000
98
const HOURS_PER_EPOCH = 4 * HOUR
109
const SECS_PER_DAY = 24 * HOUR

packages/neuron-ui/src/components/GeneralSetting/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { useSearchParams } from 'react-router-dom'
44
import Dialog from 'widgets/Dialog'
55
import LanguageDialog from 'components/LanguageDialog'
66
import AlertDialog from 'widgets/AlertDialog'
7-
import { ReactComponent as VersionLogo } from 'widgets/Icons/VersionLogo.svg'
8-
import { ReactComponent as ArrowNext } from 'widgets/Icons/ArrowNext.svg'
9-
import { ReactComponent as Update } from 'widgets/Icons/Update.svg'
7+
import VersionLogo from 'widgets/Icons/VersionLogo.svg?react'
8+
import ArrowNext from 'widgets/Icons/ArrowNext.svg?react'
9+
import Update from 'widgets/Icons/Update.svg?react'
1010
import { cancelCheckUpdates, downloadUpdate, installUpdate, getVersion } from 'services/remote'
1111
import { uniformTimeFormatter, bytesFormatter, clsx, wakeScreen, releaseWakeLock } from 'utils'
1212
import Switch from 'widgets/Switch'

packages/neuron-ui/src/components/HardwareSign/success.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useTranslation } from 'react-i18next'
33
import { useNavigate } from 'react-router-dom'
44
import { RoutePath } from 'utils'
55
import Button from 'widgets/Button'
6-
import { ReactComponent as CompleteIcon } from 'widgets/Icons/Complete.svg'
6+
import CompleteIcon from 'widgets/Icons/Complete.svg?react'
77

88
import styles from './hardwareSign.module.scss'
99

0 commit comments

Comments
 (0)