Skip to content

Commit

Permalink
Migrate from CRA to vite (#58)
Browse files Browse the repository at this point in the history
* Migrate to vite

* Remove ip from .env
  • Loading branch information
NoahBres committed Mar 16, 2021
1 parent fc113cf commit 29f78cb
Show file tree
Hide file tree
Showing 20 changed files with 253 additions and 180 deletions.
4 changes: 2 additions & 2 deletions FtcDashboard/dash/.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
REACT_APP_HOST=
REACT_APP_PORT=8000
VITE_REACT_APP_HOST=
VITE_REACT_APP_PORT=8000
1 change: 0 additions & 1 deletion FtcDashboard/dash/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"rules": {
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
"react/react-in-jsx-scope": "off",
"react/jsx-filename-extension": [
1,
{
Expand Down
8 changes: 0 additions & 8 deletions FtcDashboard/dash/craco.config.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
<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>
23 changes: 12 additions & 11 deletions FtcDashboard/dash/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
"version": "0.4.1",
"private": true,
"dependencies": {
"@craco/craco": "^6.0.0",
"@headlessui/react": "^0.3.1",
"@tailwindcss/forms": "^0.2.1",
"@tailwindcss/postcss7-compat": "npm:@tailwindcss/postcss7-compat@^2.0.2",
"autoprefixer": "^9.8.6",
"autoprefixer": "^10.2.5",
"husky": "^4.3.5",
"lint-staged": "^10.5.3",
"postcss": "^7.0.35",
"postcss": "^8.2.8",
"react": "17.0.1",
"react-dom": "^16.9.0",
"react-draggable": "^4.4.3",
Expand All @@ -23,15 +21,13 @@
"redux-logger": "^3.0.6",
"redux-thunk": "^2.3.0",
"styled-components": "^5.2.1",
"tailwindcss": "npm:@tailwindcss/postcss7-compat@^2.0.2",
"typescript": "^4.2.3",
"tailwindcss": "^2.0.3",
"uuid": "^8.3.2"
},
"scripts": {
"start": "craco start",
"build": "craco build",
"test": "craco test",
"eject": "react-scripts eject",
"start": "vite",
"build": "tsc && vite build",
"serve": "vite preview",
"lint": "eslint 'src/**/*.{js,jsx,ts,tsx,json}' --fix",
"format": "prettier --write 'src/**/*.{js,jsx,ts,tsx,json,css,scss,md}'"
},
Expand All @@ -52,6 +48,7 @@
]
},
"devDependencies": {
"@tailwindcss/jit": "^0.1.1",
"@types/lodash": "^4.14.165",
"@types/node": "^14.14.12",
"@types/react": "^17.0.0",
Expand All @@ -68,12 +65,16 @@
"@types/uuid": "^8.3.0",
"@typescript-eslint/eslint-plugin": "^4.9.1",
"@typescript-eslint/parser": "^4.9.1",
"@vitejs/plugin-react-refresh": "^1.3.1",
"eslint-config-airbnb-typescript-prettier": "^4.1.0",
"eslint-config-prettier": "^7.0.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-prettier": "^3.2.0",
"eslint-plugin-react": "^7.21.5",
"prettier": "^2.2.1"
"prettier": "^2.2.1",
"typescript": "^4.2.3",
"vite": "^2.1.0",
"vite-plugin-svgr": "^0.2.0"
},
"husky": {
"hooks": {
Expand Down
6 changes: 6 additions & 0 deletions FtcDashboard/dash/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
plugins: {
'@tailwindcss/jit': {},
autoprefixer: {},
},
};
2 changes: 0 additions & 2 deletions FtcDashboard/dash/public/robots.txt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useRef } from 'react';
import React, { useRef } from 'react';
import styled from 'styled-components';

import { WithChildren } from '../../typeHelpers';
Expand Down
2 changes: 1 addition & 1 deletion FtcDashboard/dash/src/components/ToolTip.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useRef, FunctionComponent, RefObject, ReactNode } from 'react';
import React, { useRef, FunctionComponent, RefObject, ReactNode } from 'react';
import { createPortal } from 'react-dom';

import styled from 'styled-components';
Expand Down
1 change: 1 addition & 0 deletions FtcDashboard/dash/src/containers/ConfigView.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react';
import { useDispatch, useSelector } from 'react-redux';

import CustomVariable from './CustomVariable';
Expand Down
4 changes: 2 additions & 2 deletions FtcDashboard/dash/src/containers/Dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class Dashboard extends Component {
componentDidMount() {
this.props.dispatch(
connect(
process.env.REACT_APP_HOST || window.location.hostname,
process.env.REACT_APP_PORT,
import.meta.env['VITE_REACT_APP_HOST'] || window.location.hostname,
import.meta.env['VITE_REACT_APP_PORT'],
),
);
this.props.dispatch(getLayoutPreset());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState, useEffect, useRef } from 'react';
import React, { useState, useEffect, useRef } from 'react';

import {
GridChildComponentProps,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import React, {
useState,
useEffect,
useReducer,
Expand Down
2 changes: 1 addition & 1 deletion FtcDashboard/dash/src/containers/OpModeView.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, ChangeEvent } from 'react';
import React, { Component, ChangeEvent } from 'react';
import { connect, ConnectedProps } from 'react-redux';

import styled from 'styled-components';
Expand Down
1 change: 1 addition & 0 deletions FtcDashboard/dash/src/containers/TelemetryView.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react';
import { useSelector } from 'react-redux';

import BaseView, {
Expand Down
1 change: 0 additions & 1 deletion FtcDashboard/dash/src/enums/LayoutPreset.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';

import { Values } from '../typeHelpers';

import TileGrid from '../components/TileGrid';
Expand Down
1 change: 1 addition & 0 deletions FtcDashboard/dash/src/index.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import Dashboard from './containers/Dashboard';
Expand Down
11 changes: 3 additions & 8 deletions FtcDashboard/dash/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"lib": ["dom", "dom.iterable", "esnext"],
"types": ["vite/client"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
Expand All @@ -20,7 +17,5 @@
"noEmit": true,
"jsx": "react-jsx"
},
"include": [
"src"
]
"include": ["src"]
}
8 changes: 8 additions & 0 deletions FtcDashboard/dash/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineConfig } from 'vite';
import reactRefresh from '@vitejs/plugin-react-refresh';
import svgr from 'vite-plugin-svgr';

// https://vitejs.dev/config/
export default defineConfig({
plugins: [reactRefresh(), svgr()],
});
Loading

0 comments on commit 29f78cb

Please sign in to comment.