Skip to content

Commit

Permalink
refactor: use vite as dev tool (#428) (#442)
Browse files Browse the repository at this point in the history
* refactor: use vite as dev tool
chore: remove unused deps

* build: change outDir
scripts: add build&serve

* spec node version

* chore: add proxy redirect
chore: remove old index.html

* try fix heroku

* Revert "try fix heroku"

This reverts commit aa42f99.

* host from /client

* chore: set base by different commands
chore: make antd.less only include once

* chore: clean up

* chore: add peer deps

* chore: up deps

* chore: up deps

* chore: remove unused js lib
doc: add doc on vite config

* chore: up react 18
chore: remove unused deps

* chore: up vite

* docker: base path based on env

* chore: enable gzip

* add preload to js

* preload more asset

* use brotil again

* up quality

* return to gzip

Co-authored-by: mikelxk <[email protected]>

Co-authored-by: Siyu Chen <[email protected]>
  • Loading branch information
mikelxk and syuChen1 authored Sep 17, 2022
1 parent 778b1ba commit e9f3ef6
Show file tree
Hide file tree
Showing 78 changed files with 1,954 additions and 12,257 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM strapi/base
FROM node:14

WORKDIR /usr/src/app/client
COPY ./client/package.json .
Expand Down
31 changes: 0 additions & 31 deletions client/craco.config.js

This file was deleted.

48 changes: 48 additions & 0 deletions client/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="casmm-icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Computation and Science Modeling through Making"
/>
<link rel="apple-touch-icon" href="/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="/manifest.json" />
<link rel="preload" as="script" href="/lib/blockly_compressed.js">
<link rel="preload" as="script" href="/lib/avrgirl-arduino.global.js">
<link rel="preload" as="script" href="/lib/blocks_compressed.js">
<link rel="preload" as="script" href="/lib/javascript_compressed.js">
<link rel="preload" as="script" href="/lib/en.js">
<title>CaSMM</title>
<!--libraries for style-->
<link
rel="stylesheet"
href="https://use.fontawesome.com/releases/v5.9.0/css/all.css"
/>
<!-- libraries for blockly -->
<!-- depreciated comes first as the other files may depend on it-->
<script src="/lib/depreciated.js"></script>
<script src="/lib/blockly_compressed.js"></script>
<script src="/lib/blocks_compressed.js"></script>
<script src="/lib/en.js"></script>
<!-- here are the libraries to get code from the blocks -->
<script src="/lib/arduino_compressed.js"></script>
<script src="/lib/javascript_compressed.js"></script>
<script src="/lib/avrgirl-arduino.global.js"></script>
<script>
const global = globalThis
</script>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script type="module" src="./src/index.jsx"></script>
</body>
</html>
35 changes: 17 additions & 18 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,30 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@craco/craco": "^5.9.0",
"@material-ui/core": "^4.12.3",
"@material-ui/icons": "^4.11.2",
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^12.0.0",
"@testing-library/user-event": "^7.1.2",
"antd": "^4.16.12",
"axios": "^0.21.1",
"craco-less": "^1.18.0",
"@vitejs/plugin-react": "^2.0.1",
"antd": "^4.22.8",
"axios": "^0.27.2",
"cross-env": "^7.0.3",
"emoji-picker-react": "^3.4.8",
"emoji-picker-react": "^3.6.1",
"http-server": "^0.12.3",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-hooks-global-state": "^1.0.2",
"less": "^4.1.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hooks-global-state": "^2.0.0",
"react-papaparse": "^3.17.1",
"react-router-dom": "6.2.1",
"react-scripts": "^4.0.3",
"recharts": "^2.1.5",
"strapi-provider-email-nodemailer": "^3.6.8",
"util": "^0.12.4",
"react-router-dom": "^6.3.0",
"recharts": "^2.1.13",
"vite": "^3.0.9",
"yarn": "^1.22.10"
},
"scripts": {
"start": "craco start",
"start": "vite",
"start-build": "http-server build -p 3000",
"build": "craco build",
"eject": "react-scripts eject"
"build": "vite build",
"serve": "vite serve"
},
"eslintConfig": {
"extends": "react-app"
Expand All @@ -46,5 +42,8 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"vite-plugin-compression": "^0.5.1"
}
}
66 changes: 0 additions & 66 deletions client/public/index.html

This file was deleted.

24 changes: 12 additions & 12 deletions client/src/App.js → client/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@ import React from 'react';
import { Route, Routes } from 'react-router-dom';
import PrivateRoute from './Utils/PrivateRoute';

import Home from './views/Home/Home';
import About from './views/About/About';
import Dashboard from './views/Mentor/Dashboard/Dashboard';
import Student from './views/Student/Student';
import NotFound from './views/NotFound';
import StudentLogin from './views/StudentLogin/StudentLogin';
import BlocklyPage from './views/BlocklyPage/BlocklyPage';
import Classroom from './views/Mentor/Classroom/Classroom';
import TeacherLogin from './views/TeacherLogin/TeacherLogin';
import ContentCreator from './views/ContentCreator/ContentCreator';
import ForgetPassword from './views/TeacherLogin/ForgetPassword';
import ResetPassword from './views/TeacherLogin/ResetPassword';
import BugReport from './views/BugReport/BugReport';
import Report from './views/Researcher/Report';
import ContentCreator from './views/ContentCreator/ContentCreator';
import Home from './views/Home/Home';
import Classroom from './views/Mentor/Classroom/Classroom';
import Dashboard from './views/Mentor/Dashboard/Dashboard';
import NotFound from './views/NotFound';
import Replay from './views/Replay/Replay';
import DayLevelReport from './views/Researcher/DayLevelReport';
import DayLevelReportView from './views/Researcher/DayLevelReportView';
import GroupReport from './views/Researcher/GroupReport';
import Replay from './views/Replay/Replay';
import Report from './views/Researcher/Report';
import Student from './views/Student/Student';
import StudentLogin from './views/StudentLogin/StudentLogin';
import ForgetPassword from './views/TeacherLogin/ForgetPassword';
import ResetPassword from './views/TeacherLogin/ResetPassword';
import TeacherLogin from './views/TeacherLogin/TeacherLogin';

const App = () => {
return (
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 0 additions & 2 deletions client/src/assets/style.less
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@import '~antd/dist/antd.less';


#colors() {
primary: #3D5C82;
Expand Down
File renamed without changes.
File renamed without changes.
15 changes: 7 additions & 8 deletions client/src/index.js → client/src/index.jsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import React from 'react';
import { render } from 'react-dom';
import './index.less';
import { createRoot } from 'react-dom/client'
import { BrowserRouter } from 'react-router-dom'
import App from './App';
import { BrowserRouter } from 'react-router-dom';
import './index.less';
import * as serviceWorker from './serviceWorker';

render(
const container = document.getElementById("root")
createRoot(container).render(
<BrowserRouter>
<App />
</BrowserRouter>,
document.getElementById('root')
);
</BrowserRouter>
)

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
Expand Down
1 change: 1 addition & 0 deletions client/src/index.less
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@import 'antd/dist/antd.less';
@import './assets/style.less';

body {
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.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
43 changes: 43 additions & 0 deletions client/vite.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import react from "@vitejs/plugin-react"
import { defineConfig } from "vite"

const base = process.env.PUBLIC_URL ?? "/"

export default defineConfig({
css: {
preprocessorOptions: {
less: {
modifyVars: {
"@primary-color": "#3d5c82", // primary color for all components
"@link-color": "#3d5c82", // link color
"@success-color": "#52c41a", // success state color
"@warning-color": "#faad14", // warning state color
"@error-color": "#f5222d", // error state color
"@font-size-base": "14px", // major text font size
"@heading-color": "rgba(0, 0, 0, 0.85)", // heading text color
"@text-color": "rgba(0, 0, 0, 0.65)", // major text color
"@text-color-secondary": "rgba(0, 0, 0, 0.45)", // secondary text color
"@disabled-color": "rgba(0, 0, 0, 0.25)", // disable state color
"@border-radius-base": "4px", // major border radius
"@border-color-base": "#d9d9d9", // major border color
"@box-shadow-base": "0 2px 8px rgba(0, 0, 0, 0.15)", // major shadow for layers
},
javascriptEnabled: true,
},
},
},
//in build mode, the output will be copoied to server/puiblic/client
base,
plugins: [react()],
server: {
port: 3000,
proxy: {
"/api": {
target: "http://localhost:1337",
},
},
},
build: {
outDir: "build",
},
})
Loading

0 comments on commit e9f3ef6

Please sign in to comment.