Skip to content

Commit

Permalink
Merge pull request #160 from Exabyte-io/chore/replace-cra-with-vite
Browse files Browse the repository at this point in the history
chore/replace cra with vite
  • Loading branch information
timurbazhirov authored Jan 16, 2025
2 parents ff74e1f + 5fcb64b commit 1084bd0
Show file tree
Hide file tree
Showing 8 changed files with 13,713 additions and 28,289 deletions.
3 changes: 2 additions & 1 deletion babel.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"@babel/preset-typescript"
],
"plugins": [
"@babel/plugin-proposal-class-properties"
"@babel/plugin-proposal-class-properties",
"@emotion/babel-plugin"
]
}

24 changes: 0 additions & 24 deletions craco.config.js

This file was deleted.

15 changes: 15 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no">
<title>Materials Designer</title>
<!-- URL-encoded svg favicon with theme-aware styles -->
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20version%3D%221.1%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%20xmlns%3Asvgjs%3D%22http%3A%2F%2Fsvgjs.com%2Fsvgjs%22%20width%3D%22512%22%20height%3D%22512%22%3E%3Cstyle%3E%40media%20%28prefers-color-scheme%3Alight%29%7B.theme-color%7Bfill%3A%23000000%7D%7D%40media%20%28prefers-color-scheme%3Adark%29%7B.theme-color%7Bfill%3A%23FFFFFF%7D%7D%3C%2Fstyle%3E%3Csvg%20width%3D%22512%22%20height%3D%22512%22%20viewBox%3D%220%200%20512%20512%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Ccircle%20class%3D%22theme-color%22%20cx%3D%22256%22%20cy%3D%22256%22%20r%3D%2280%22%20transform%3D%22rotate%28-180%20256%20256%29%22%3E%3C%2Fcircle%3E%3Cpath%20class%3D%22theme-color%22%20d%3D%22M334%20100.056C334%2050.8718%20373.847%2011%20423%2011C472.153%2011%20512%2050.8718%20512%20100.056C512%20130.306%20480.115%20171.982%20480.115%20171.982C480.115%20171.982%20427.327%20236.133%20427.327%20256.326C427.327%20276.516%20456.851%20312.743%20480.115%20341.285C497.341%20362.431%20512%20383.184%20512%20411.944C512%20461.128%20472.153%20501%20423%20501C373.847%20501%20334%20461.128%20334%20411.944C334%20384.78%20349.322%20361.543%20365.887%20341.285C389.152%20312.74%20418.674%20276.516%20418.674%20256.326C418.674%20236.289%20366.784%20171.982%20366.784%20171.982C366.784%20171.982%20334%20131.672%20334%20100.056Z%22%20fill%3D%22%23000000%22%3E%3C%2Fpath%3E%3Cpath%20class%3D%22theme-color%22%20d%3D%22M0%20100.056C0%2050.8718%2039.8467%2011%2089%2011C138.153%2011%20178%2050.8718%20178%20100.056C178%20130.306%20146.115%20171.982%20146.115%20171.982C146.115%20171.982%2093.3276%20236.133%2093.3276%20256.326C93.3276%20276.516%20122.851%20312.743%20146.115%20341.285C163.341%20362.431%20178%20383.184%20178%20411.944C178%20461.128%20138.153%20501%2089%20501C39.8467%20501%200%20461.128%200%20411.944C0%20384.78%2015.3226%20361.543%2031.8867%20341.285C55.1519%20312.74%2084.6738%20276.516%2084.6738%20256.326C84.6738%20236.289%2032.7845%20171.982%2032.7845%20171.982C32.7845%20171.982%200%20131.672%200%20100.056Z%22%20fill%3D%22%23000000%22%3E%3C%2Fpath%3E%3C%2Fsvg%3E%3C%2Fsvg%3E" />
</head>
<body>
<noscript>Please enable JavaScript to view this website correctly.</noscript>
<div id="root"></div>
<script type="module" src="./src/index.jsx"></script>
</body>
</html>
41,898 changes: 13,653 additions & 28,245 deletions package-lock.json

Large diffs are not rendered by default.

16 changes: 11 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version": "0.0.0",
"description": "Web-based Atomic Viewer and Editor in JavaScript.",
"scripts": {
"build": "SKIP_PREFLIGHT_CHECK=true craco --openssl-legacy-provider build",
"start": "cross-env PORT=3002 SKIP_PREFLIGHT_CHECK=true craco --openssl-legacy-provider start",
"build": "npm run transpile && vite build",
"start": "vite",
"transpile": "tsc && npm run copy-css",
"copy-css": "mkdir -p dist/stylesheets && cp src/stylesheets/* dist/stylesheets/",
"prestart": "npm-link-shared ./node_modules/@exabyte-io/cove.js/node_modules . react",
Expand Down Expand Up @@ -43,7 +43,6 @@
"moment": "^2.29.4",
"pixelmatch": "^5.3.0",
"prop-types": "^15.8.0",
"react-scripts": "^4.0.3",
"sprintf-js": "^1.1.2",
"static-kdtree": "^1.0.2",
"three": "npm:@exabyte-io/[email protected]",
Expand All @@ -60,7 +59,6 @@
"react-dom": "^17.0.0"
},
"devDependencies": {
"@craco/craco": "^6.4.5",
"@exabyte-io/cove.js": "2024.7.31-0",
"@exabyte-io/eslint-config": "^2025.1.15-0",
"@mat3ra/code": "^2024.3.25-3",
Expand All @@ -72,6 +70,7 @@
"@types/underscore": "^1.11.9",
"@typescript-eslint/eslint-plugin": "^5.56.0",
"@typescript-eslint/parser": "^5.56.0",
"@vitejs/plugin-react": "^4.3.4",
"@wojtekmaj/enzyme-adapter-react-17": "^0.8.0",
"cross-env": "^7.0.3",
"enzyme": "^3.11.0",
Expand All @@ -83,6 +82,7 @@
"eslint-plugin-jsx-a11y": "6.5.1",
"eslint-plugin-mui-path-imports": "0.0.15",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.37.4",
"eslint-plugin-simple-import-sort": "7.0.0",
"expect": "27.4.2",
"gl": "^8.1.6",
Expand All @@ -92,6 +92,7 @@
"jest-environment-jsdom": "^27.5.1",
"jest-image-snapshot": "^5.0.0",
"jest-matcher-deep-close-to": "1.3.0",
"jsdom": "^26.0.0",
"lint-staged": "^12.1.2",
"looks-same": "^9.0.0",
"npm-link-shared": "^0.5.6",
Expand All @@ -100,7 +101,12 @@
"react": "^17.0.0",
"react-dom": "^17.0.0",
"react-error-overlay": "^6.0.9",
"react-test-renderer": "^17.0.0"
"react-test-renderer": "^17.0.0",
"vite": "^6.0.7",
"vite-plugin-commonjs": "^0.10.4",
"vite-plugin-node-polyfills": "^0.22.0",
"vite-plugin-svgr": "^4.3.0",
"vite-tsconfig-paths": "^5.1.4"
},
"resolutions": {
"react-error-overlay": "6.0.9"
Expand Down
12 changes: 0 additions & 12 deletions public/index.html

This file was deleted.

2 changes: 0 additions & 2 deletions tests/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,6 @@ export async function takeSnapshotAndAssertEqualityAsync(webGLContext, imagePref
fs.writeFileSync(diffImageFilePath, PNG.sync.write(diff));
}

// Log the result and return true if the images match within the threshold
console.log(`Number of differing pixels: ${numDiffPixels}`);
expect(numDiffPixels).toBe(0);
}

Expand Down
32 changes: 32 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";
import { nodePolyfills } from "vite-plugin-node-polyfills";

// https://vite.dev/config/
export default defineConfig({
plugins: [
react({
jsxImportSource: "@emotion/react",
babel: {
plugins: ["@emotion/babel-plugin"],
},
}),
nodePolyfills(),
],
define: {
__dirname: JSON.stringify(__dirname), // fix for node.js modules in client bundle
},
server: {
port: 3002,
},
build: {
outDir: "build",
rollupOptions: {
output: {
entryFileNames: "main.js", // Name the main output bundle as main.js
chunkFileNames: "[name]-[hash].js", // Optional: Name for dynamic imports or shared chunks
assetFileNames: "[name]-[hash].[ext]", // Optional: Name for assets like CSS or images
},
},
},
});

0 comments on commit 1084bd0

Please sign in to comment.