Skip to content

Commit

Permalink
Move from CRA to Vite
Browse files Browse the repository at this point in the history
  • Loading branch information
pyamsoft committed May 6, 2023
1 parent 7ea4297 commit 400d5b5
Show file tree
Hide file tree
Showing 13 changed files with 1,098 additions and 7,327 deletions.
30 changes: 30 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright 2023 pyamsoft
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

module.exports = {
env: { browser: true, es2020: true },
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended",
],
parser: "@typescript-eslint/parser",
parserOptions: { ecmaVersion: "latest", sourceType: "module" },
plugins: ["react-refresh"],
rules: {
"react-refresh/only-export-components": "warn",
},
};
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

# production
/build
/dist

# misc
.DS_Store
Expand Down
2 changes: 1 addition & 1 deletion firebase.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"hosting": {
"public": "build",
"public": "dist",
"ignore": [
"firebase.json",
"**/.*",
Expand Down
37 changes: 37 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!--
~ Copyright 2023 pyamsoft
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Ride Roulette"
/>
<link rel="apple-touch-icon" href="/logo192.png" />
<link rel="manifest" href="/manifest.json" />
<title>Ride Roulette</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script type="module" src="/src/index.tsx"></script>
</body>
</html>
47 changes: 16 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ride-roulette",
"version": "0.1.3",
"version": "0.1.4",
"private": true,
"dependencies": {
"@emotion/react": "11.10.6",
Expand All @@ -10,49 +10,34 @@
"react": "18.2.0",
"react-confetti": "6.1.0",
"react-dom": "18.2.0",
"react-scripts": "5.0.1",
"react-window": "1.8.8",
"typescript": "5.0.3",
"uuid": "9.0.0",
"web-vitals": "3.3.0"
"uuid": "9.0.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"start": "vite",
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"build": "rm -rf dist && tsc && vite build",
"preview": "yarn build && vite preview",
"deploy": "yarn build && firebase deploy"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@testing-library/jest-dom": "5.16.5",
"@testing-library/react": "14.0.0",
"@testing-library/user-event": "14.4.3",
"@types/jest": "29.5.0",
"@types/node": "18.15.11",
"@types/react": "18.0.32",
"@types/react-dom": "18.0.11",
"@types/react-window": "1.8.5",
"@types/uuid": "9.0.1",
"@typescript-eslint/eslint-plugin": "5.59.2",
"@typescript-eslint/parser": "5.59.2",
"@vitejs/plugin-react": "4.0.0",
"eslint": "8.40.0",
"eslint-plugin-react-hooks": "4.6.0",
"eslint-plugin-react-refresh": "0.4.1",
"firebase-tools": "11.25.2",
"npm-check-updates": "16.10.0",
"prettier": "2.8.7"
"prettier": "2.8.7",
"typescript": "5.0.3",
"vite": "4.3.5",
"web-vitals": "3.3.0"
}
}
43 changes: 0 additions & 43 deletions public/index.html

This file was deleted.

1 change: 0 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/

import React from "react";
import ReactDOM from "react-dom/client";
import "./index.css";
import reportWebVitals from "./reportWebVitals";
Expand Down
2 changes: 1 addition & 1 deletion src/pages/roulette/DisneyAttractions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export const getHardcodedParks = function (props: {
includeEntertainment: boolean;
}): Attraction[] {
// Future: We want to use the date to filter out seasonal attractions like Halloween and Christmas rides.
const { date, includeEntertainment } = props;
const { includeEntertainment } = props;

let at = [
createDLRNewAttraction({
Expand Down
2 changes: 1 addition & 1 deletion src/react-app-env.d.ts → src/vite-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
* limitations under the License.
*/

/// <reference types="react-scripts" />
/// <reference types="vite/client" />
37 changes: 19 additions & 18 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"target": "ESNext",
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"module": "ESNext",
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
"jsx": "react-jsx",

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitOverride": true,
"noImplicitThis": true,
},
"include": [
"src"
]
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}
10 changes: 10 additions & 0 deletions tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}
67 changes: 67 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright 2023 pyamsoft
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { defineConfig, splitVendorChunkPlugin, UserConfigExport } from "vite";
import react from "@vitejs/plugin-react";

// https://vitejs.dev/config/
export default defineConfig(({ command, mode }) => {
const baseConfig: UserConfigExport = {
plugins: [react(), splitVendorChunkPlugin()],
};

const isProduction = mode === "production";

if (command === "build") {
return {
...baseConfig,
build: {
target: "es2015",
sourcemap: true,
minify: isProduction,
cssMinify: true,
rollupOptions: {
output: {
manualChunks: (path: string) => {
if (path.includes("/node_modules")) {
if (path.includes("@mui")) {
if (path.includes("icons-material")) {
return "vendor_mui_icons_material";
} else {
return "vendor_mui";
}
}

return "vendor";
}

// Fallback to split chunk plugin
return undefined;
},
},
},
},
};
} else {
return {
...baseConfig,
server: {
port: 3000,
strictPort: true,
},
};
}
});
Loading

0 comments on commit 400d5b5

Please sign in to comment.