Skip to content

Commit

Permalink
Move from Webpack to Vite
Browse files Browse the repository at this point in the history
  • Loading branch information
0x46616c6b committed Jan 7, 2024
1 parent e4ad8e1 commit 928e50e
Show file tree
Hide file tree
Showing 70 changed files with 1,217 additions and 5,827 deletions.
20 changes: 0 additions & 20 deletions .babelrc

This file was deleted.

1 change: 1 addition & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TICKER_API_URL="http://localhost:8080/v1"
40 changes: 18 additions & 22 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@ updates:
patterns:
- "@tanstack/*"
- "@types/react"
- "@types/react-helmet"
- "react"
- "react-*"
leaflet:
patterns:
- "leaflet"
- "leaflet-*"
- "react-leaflet"
- "react-leaflet-*"
mui:
patterns:
- "@emotion/*"
Expand All @@ -26,33 +31,24 @@ updates:
- "@mui/*"
development:
patterns:
- "@babel/*"
- "@testing-library/*"
- "@types/*"
- "@types/jest"
- "@types/jwt-decode"
- "@types/node"
- "@types/react-dom"
- "@types/react-router-dom"
- "@typescript-eslint/*"
- "babel-*"
- "css-loader"
- "@vitejs/plugin-react"
- "@vitest/coverage-v8"
- "cssnano"
- "dotenv"
- "dotenv-*"
- "eslint"
- "eslint-*"
- "file-loader"
- "html-webpack-plugin"
- "identity-obj-proxy"
- "jest"
- "jest-*"
- "jsdom"
- "jwt-encode"
- "postcss"
- "postcss-*"
- "prettier"
- "prettier-*"
- "resolve"
- "resolove-url-loader"
- "style-loader"
- "terser-webpack-plugin"
- "ts-*"
- "typescript"
- "typescript-*"
- "url-loader"
- "webpack"
- "webpack-*"
- "vite"
- "vitest"
- "vitest-*"
10 changes: 5 additions & 5 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ jobs:
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: "18"
cache: "yarn"
node-version: '18'
cache: 'yarn'

- name: Install Dependencies
run: yarn install --frozen-lockfile

- name: Test
run: yarn run test --coverage
run: yarn run coverage

- name: Codecov
uses: codecov/codecov-action@v3
Expand All @@ -37,7 +37,7 @@ jobs:
needs: [test]
strategy:
matrix:
node-version: ["18", "20", "current"]
node-version: ['18', '20', 'current']

steps:
- name: Checkout
Expand All @@ -47,7 +47,7 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"
cache: 'yarn'

- name: Install Dependencies
run: yarn install --frozen-lockfile
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

## Development

**Requirement:** Running instance of [ticker](https://github.com/systemli/ticker), default: http://localhost:8080/v1
**Requirement:** Running instance of [ticker](https://github.com/systemli/ticker), default: <http://localhost:8080/v1>

```
```shell
# Install dependencies
yarn

Expand All @@ -16,6 +16,6 @@ yarn start

Place configuration in `.env` file and restart/rebuild the ticker-admin

```
REACT_APP_API_URL=http://localhost:8080/v1
```shell
TICKER_API_URL=http://localhost:8080/v1
```
13 changes: 13 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="icon" href="/favicon.ico" type="image/x-icon">
<title>Ticker Admin</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
10 changes: 0 additions & 10 deletions jest-setup.ts

This file was deleted.

22 changes: 0 additions & 22 deletions jest.config.ts

This file was deleted.

66 changes: 18 additions & 48 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{
"name": "ticker-admin",
"type": "module",
"scripts": {
"start": "webpack serve --config webpack.dev.config.ts",
"test": "jest --silent --maxWorkers 2",
"build": "webpack --config webpack.prod.config.ts"
"build": "vite build",
"dev": "vite",
"preview": "vite preview",
"test": "vitest",
"coverage": "vitest run --coverage",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0"
},
"dependencies": {
"@emotion/react": "^11.11.0",
Expand All @@ -17,11 +21,12 @@
"@mui/material": "^5.14.11",
"@tanstack/react-query": "^4.10.3",
"@tanstack/react-query-devtools": "^4.11.0",
"@types/react": "^18.2.0",
"dayjs": "^1.11.10",
"jwt-decode": "^4.0.0",
"leaflet": "^1.9.2",
"leaflet-draw": "^1.0.4",
"lodash": "^4.17.21",
"moment": "^2.30.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.45.1",
Expand All @@ -34,12 +39,8 @@
"react-router-dom": "^6.21.1"
},
"devDependencies": {
"@babel/core": "^7.23.7",
"@babel/plugin-transform-runtime": "^7.23.7",
"@babel/preset-env": "^7.23.7",
"@babel/preset-react": "^7.23.3",
"@babel/preset-typescript": "^7.23.3",
"@testing-library/jest-dom": "^6.1.6",
"@testing-library/dom": "^9.3.3",
"@testing-library/jest-dom": "6.1.6",
"@testing-library/react": "^14.1.2",
"@testing-library/user-event": "^14.5.2",
"@types/jest": "^29.5.11",
Expand All @@ -51,52 +52,21 @@
"@types/react-router-dom": "^5.3.3",
"@typescript-eslint/eslint-plugin": "^6.16.0",
"@typescript-eslint/parser": "^6.16.0",
"@webpack-cli/serve": "^1.7.0",
"babel-eslint": "^10.1.0",
"babel-loader": "^9.1.3",
"css-loader": "^6.8.1",
"@vitejs/plugin-react": "^4.2.1",
"@vitest/coverage-v8": "^1.1.3",
"cssnano": "^6.0.2",
"dotenv": "^16.3.1",
"dotenv-expand": "^10.0.0",
"dotenv-webpack": "^8.0.1",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-react-app": "^7.0.1",
"eslint-plugin-flowtype": "^8.0.3",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest": "^27.6.0",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-prettier": "^5.1.2",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-testing-library": "^6.2.0",
"eslint-webpack-plugin": "^4.0.1",
"file-loader": "^6.2.0",
"html-webpack-plugin": "^5.6.0",
"jest": "^29.7.0",
"jest-dom": "^4.0.0",
"jest-environment-jsdom": "^29.7.0",
"jest-fetch-mock": "^3.0.3",
"jest-transform-stub": "^2.0.0",
"eslint-plugin-react-refresh": "^0.4.5",
"jsdom": "^23.2.0",
"jwt-encode": "^1.0.1",
"postcss": "^8.4.32",
"postcss-loader": "^7.3.4",
"postcss-remove-google-fonts": "^1.2.3",
"prettier": "^3.1.1",
"react-dev-utils": "^12.0.1",
"resolve": "^1.22.1",
"resolve-url-loader": "^5.0.0",
"style-loader": "^3.3.3",
"terser-webpack-plugin": "^5.3.10",
"ts-jest": "^29.1.1",
"ts-loader": "^9.5.1",
"ts-node": "^10.9.2",
"typescript": "^5.3.3",
"url-loader": "^4.1.1",
"webpack": "^5.89.0",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.15.1",
"webpack-manifest-plugin": "^5.0.0",
"webpack-merge": "^5.10.0"
"vite": "^5.0.11",
"vitest": "^1.1.3",
"vitest-fetch-mock": "^0.2.2"
}
}
File renamed without changes.
16 changes: 0 additions & 16 deletions public/index.html

This file was deleted.

2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC } from 'react'
import { FC } from 'react'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { ReactQueryDevtools } from '@tanstack/react-query-devtools'
import { BrowserRouter, Route, Routes } from 'react-router-dom'
Expand Down
2 changes: 1 addition & 1 deletion src/api/Api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const ApiUrl = process.env.REACT_APP_API_URL || 'http://localhost:8080/v1'
export const ApiUrl = import.meta.env.TICKER_API_URL

type StatusSuccess = 'success'
type StatusError = 'error'
Expand Down
10 changes: 5 additions & 5 deletions src/api/Auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { login } from './Auth'

describe('Auth', function () {
beforeEach(() => {
fetchMock.resetMocks()
fetchMock.doMock()
fetch.resetMocks()
fetch.doMock()
})

test('login failed', function () {
fetchMock.mockResponse(
fetch.mockResponse(
JSON.stringify({
data: {},
status: 'error',
Expand All @@ -20,7 +20,7 @@ describe('Auth', function () {
})

test('server error', function () {
fetchMock.mockReject()
fetch.mockReject()

expect(login('[email protected]', 'password')).rejects.toThrow('Login failed')
})
Expand All @@ -31,7 +31,7 @@ describe('Auth', function () {
expire: '2022-10-01T18:22:37+02:00',
token: 'token',
}
fetchMock.mockResponse(JSON.stringify(response), { status: 200 })
fetch.mockResponse(JSON.stringify(response), { status: 200 })

expect(login('[email protected]', 'password')).resolves.toEqual(response)
})
Expand Down
2 changes: 1 addition & 1 deletion src/components/Loader.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CircularProgress, Stack, Typography } from '@mui/material'
import React, { FC } from 'react'
import { FC } from 'react'

const Loader: FC = () => {
return (
Expand Down
2 changes: 1 addition & 1 deletion src/components/ProtectedRoute.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC } from 'react'
import { FC } from 'react'
import { Navigate, RouteProps } from 'react-router'
import useAuth, { Roles } from './useAuth'

Expand Down
2 changes: 1 addition & 1 deletion src/components/common/NamedListItem.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC } from 'react'
import { FC } from 'react'
import { Box, Typography } from '@mui/material'

interface Props {
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/TabPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Box } from '@mui/material'
import React, { FC } from 'react'
import { FC } from 'react'

interface Props {
children?: React.ReactNode
Expand Down
2 changes: 1 addition & 1 deletion src/components/message/AttachmentPreview.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC } from 'react'
import { FC } from 'react'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { IconButton, ImageListItem } from '@mui/material'
import { Upload } from '../../api/Upload'
Expand Down
2 changes: 1 addition & 1 deletion src/components/message/AttachmentsPreview.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ImageList } from '@mui/material'
import React, { FC } from 'react'
import { FC } from 'react'
import { Upload } from '../../api/Upload'
import AttachmentPreview from './AttachmentPreview'

Expand Down
Loading

0 comments on commit 928e50e

Please sign in to comment.