Skip to content

Commit

Permalink
Vite used instead of webpack (#2)
Browse files Browse the repository at this point in the history
Vite migration instead of webpack & create-react-app
  • Loading branch information
maliksenpai authored Oct 26, 2023
1 parent 797e47e commit 0efe0bb
Show file tree
Hide file tree
Showing 61 changed files with 135 additions and 79 deletions.
4 changes: 2 additions & 2 deletions .env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
PORT=3245
REACT_APP_VERSION=$npm_package_version
REACT_APP_NAME=$npm_package_name
VITE_REACT_APP_VERSION=$npm_package_version
VITE_REACT_APP_NAME=$npm_package_name
18 changes: 18 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
46 changes: 46 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

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

# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

.idea/
Expand Down Expand Up @@ -31,3 +56,24 @@ yarn-error.log*
!.yarn/releases
!.yarn/sdks
!.yarn/versions

.history
package-lock.json
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

.history
package-lock.json
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,3 @@ This section has moved here: [https://facebook.github.io/create-react-app/docs/d
### `yarn build` fails to minify

This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)


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" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
</html>
58 changes: 39 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
{
"name": "comfort-react-demo",
"version": "3.2.2",
"type": "module",
"private": false,
"homepage": "http://obss.github.io/comfort-react-demo",
"license": "MIT",
"devDependencies": {
"@babel/core": "7.19.3",
"@babel/eslint-parser": "7.19.1",
"@babel/plugin-proposal-class-properties": "7.18.6",
"@babel/plugin-proposal-function-bind": "7.18.9",
"@babel/preset-env": "7.19.4",
"@babel/preset-react": "7.18.6",
"eslint": "8.23.1",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-prettier": "4.2.1",
"eslint-plugin-react": "7.31.8",
"eslint-plugin-react-hooks": "4.6.0",
"prettier": "2.7.1"
"scripts": {
"dev": "vite",
"build": "vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
"dependencies": {
"@emotion/cache": "11.10.3",
Expand All @@ -24,13 +18,18 @@
"@mui/icons-material": "5.10.9",
"@mui/lab": "5.0.0-alpha.103",
"@mui/material": "5.10.9",
"@mui/styles": "5.9.3",
"@mui/utils": "5.10.9",
"@mui/x-date-pickers": "5.0.4",
"@testing-library/jest-dom": "5.11.4",
"@testing-library/react": "11.1.0",
"@testing-library/user-event": "12.1.10",
"comfort-react": "3.2.2",
"date-fns": "2.29.3",
"jsx-to-string": "1.4.0",
"miragejs": "0.1.45",
"react": "18.2.0",
"react-bootstrap": "2.0.0-rc.0",
"react-dom": "18.2.0",
"react-draggable": "4.4.5",
"react-dropzone": "14.2.3",
Expand All @@ -44,12 +43,33 @@
"stylis-plugin-rtl": "2.1.1",
"web-vitals": "3.0.1"
},
"scripts": {
"start": "SET PUBLIC_URL=. && react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"predeploy": "npm run build"
"devDependencies": {
"@types/react": "^18.2.15",
"@types/react-dom": "^18.2.7",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"@vitejs/plugin-react": "^4.0.4",
"eslint-config-airbnb": "18.2.1",
"eslint-config-react-app": "6.0.0",
"eslint-plugin-flowtype": "5.10.0",
"eslint-plugin-import": "2.25.4",
"eslint-plugin-jsx-a11y": "6.5.1",
"eslint-plugin-react-refresh": "^0.4.3",
"lint-staged": "11.2.0",
"typescript": "^5.0.2",
"vite": "^4.4.5",
"@babel/core": "7.19.3",
"@babel/eslint-parser": "7.19.1",
"@babel/plugin-proposal-class-properties": "7.18.6",
"@babel/plugin-proposal-function-bind": "7.18.9",
"@babel/preset-env": "7.19.4",
"@babel/preset-react": "7.18.6",
"eslint": "8.23.1",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-prettier": "4.2.1",
"eslint-plugin-react": "7.31.8",
"eslint-plugin-react-hooks": "4.6.0",
"prettier": "2.7.1"
},
"babel": {
"presets": [
Expand Down
44 changes: 0 additions & 44 deletions public/index.html

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 2 additions & 7 deletions src/components/Main.js → src/components/Main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ const Main = () => {
<HashRouter>
<div className={'obssTriangle'}>
<a className={'triangleIcon'} href={'https://obss.tech/'} target={'_blank'} rel="noreferrer">
<img src={process.env.PUBLIC_URL + '/obss.png'} alt={'obss'} />
<img src={'/obss.png'} alt={'obss'} />
</a>
</div>
<Box flexGrow={1}>
Expand All @@ -355,12 +355,7 @@ const Main = () => {
<MenuIcon />
</IconButton>
<Link to={'/'} className="bannerLink">
<img
width={48}
className={'menuLogo'}
src={process.env.PUBLIC_URL + '/logo.png'}
alt={'logo'}
/>
<img width={48} className={'menuLogo'} src={'/logo.png'} alt={'logo'} />
<span className="bannerText">comfort-react</span>
</Link>
<Box flexGrow={1} />
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions src/components/Settings.js → src/components/Settings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { SettingsOutlined } from '@mui/icons-material';

const Settings = (props) => {
const { openSettingsDialog } = props;
const versionInfo = `Version: ${process.env.REACT_APP_VERSION}`;
const versionInfo = `Version: ${import.meta.env.VITE_REACT_APP_VERSION}`;

return (
<div className={'settings-div'}>
Expand All @@ -17,14 +17,14 @@ const Settings = (props) => {
<Tooltip placement="bottom" title="View on GitHub">
<span className={'githubIcon'}>
<a href={'https://github.com/obss/comfort-react'} target="_blank" rel="noreferrer">
<img src={process.env.PUBLIC_URL + '/github.png'} alt="github_icon" />
<img src={'/github.png'} alt="github_icon" />
</a>
</span>
</Tooltip>
<Tooltip placement="bottom" title="View on npmjs">
<span className={'npmIcon'}>
<a href={'https://www.npmjs.com/package/comfort-react'} target="_blank" rel="noreferrer">
<img src={process.env.PUBLIC_URL + '/npm.png'} alt="npm_icon" />
<img src={'/npm.png'} alt="npm_icon" />
</a>
</span>
</Tooltip>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const ComponentFormDialog = () => {
let currentJsx = jsxToString(formDialogElementJsx, {
displayName: 'FormDialog',
useFunctionCode: true,
}).replace('<[object Object]', '<TextField');;
}).replace('<[object Object]', '<TextField');

currentJsx = "import { FormDialog } from 'comfort-react';\n\n" + currentJsx;

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const Home = () => {
rowGap={5}
pt={2}
>
<img width={'200px'} src={process.env.PUBLIC_URL + '/logo.png'} alt={'logo'} />
<img width={'200px'} src={'/logo.png'} alt={'logo'} />
<Typography variant={'h3'}> comfort-react </Typography>
<Typography variant={'h6'}>
{' '}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="vite/client" />
9 changes: 9 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react({
include: '**/*.{js,jsx,tsx}',
})],
})

0 comments on commit 0efe0bb

Please sign in to comment.