chore: UI polyfills for build command (#165)

* chore: fix vite plugin for polyfills

* chore: add prod script command to run production version

* refactor: hash router to run on ipfs
This commit is contained in:
Felipe Mendes 2023-03-08 17:56:36 -03:00 committed by GitHub
parent 9db81d2025
commit 099e6d76d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 1046 additions and 1135 deletions

View File

@ -9,6 +9,7 @@
"build": "yarn graphclient build && vite build", "build": "yarn graphclient build && vite build",
"postinstall": "graphclient build", "postinstall": "graphclient build",
"preview": "vite preview", "preview": "vite preview",
"prod": "yarn build && npx serve dist -s",
"storybook": "export SET NODE_OPTIONS=--openssl-legacy-provider && start-storybook -p 6006", "storybook": "export SET NODE_OPTIONS=--openssl-legacy-provider && start-storybook -p 6006",
"build-storybook": "build-storybook" "build-storybook": "build-storybook"
}, },
@ -40,8 +41,6 @@
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.20.12", "@babel/core": "^7.20.12",
"@esbuild-plugins/node-globals-polyfill": "^0.1.1",
"@esbuild-plugins/node-modules-polyfill": "^0.2.2",
"@graphprotocol/client-cli": "^2.2.19", "@graphprotocol/client-cli": "^2.2.19",
"@storybook/addon-actions": "^6.5.15", "@storybook/addon-actions": "^6.5.15",
"@storybook/addon-essentials": "^6.5.15", "@storybook/addon-essentials": "^6.5.15",
@ -73,12 +72,12 @@
"prettier": "^2.8.0", "prettier": "^2.8.0",
"process": "^0.11.10", "process": "^0.11.10",
"react-query": "^3.39.2", "react-query": "^3.39.2",
"rollup-plugin-polyfill-node": "^0.12.0",
"storybook-dark-mode": "^2.0.5", "storybook-dark-mode": "^2.0.5",
"tailwindcss": "^3.2.4", "tailwindcss": "^3.2.4",
"ts-loader": "^9.4.1", "ts-loader": "^9.4.1",
"typescript": "^4.9.3", "typescript": "^4.9.3",
"vite": "^3.2.4", "vite": "^3.2.4",
"vite-plugin-node-polyfills": "^0.7.0",
"vite-tsconfig-paths": "^3.6.0" "vite-tsconfig-paths": "^3.6.0"
} }
} }

View File

@ -1,4 +1,4 @@
import { BrowserRouter, Route, Routes, Navigate } from 'react-router-dom'; import { HashRouter, Route, Routes, Navigate } from 'react-router-dom';
import { themeGlobals } from '@/theme/globals'; import { themeGlobals } from '@/theme/globals';
import { ComponentsTest, Home, Mint } from './views'; import { ComponentsTest, Home, Mint } from './views';
import { SVGTestScreen } from './views/svg-test'; // TODO: remove when done import { SVGTestScreen } from './views/svg-test'; // TODO: remove when done
@ -14,7 +14,7 @@ export const App = () => {
{/* TODO remove after adding NavBar */} {/* TODO remove after adding NavBar */}
<ConnectKitButton /> <ConnectKitButton />
</div> </div>
<BrowserRouter> <HashRouter>
<Routes> <Routes>
<Route path="/home" element={<Home />} /> <Route path="/home" element={<Home />} />
<Route path="/mint" element={<Mint />} /> <Route path="/mint" element={<Mint />} />
@ -25,7 +25,7 @@ export const App = () => {
<Route path="/mint-test" element={<MintTest />} /> <Route path="/mint-test" element={<MintTest />} />
<Route path="*" element={<Navigate to="/home" />} /> <Route path="*" element={<Navigate to="/home" />} />
</Routes> </Routes>
</BrowserRouter> </HashRouter>
</> </>
); );
}; };

View File

@ -1,38 +1,9 @@
import { defineConfig } from 'vite'; import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react'; import react from '@vitejs/plugin-react';
import tsconfigPaths from 'vite-tsconfig-paths'; import tsconfigPaths from 'vite-tsconfig-paths';
import EslintGlobalsPolyfills from '@esbuild-plugins/node-globals-polyfill'; import { nodePolyfills } from 'vite-plugin-node-polyfills';
import EslintModulePolyfills from '@esbuild-plugins/node-modules-polyfill';
import rollupNodePolyfill from 'rollup-plugin-polyfill-node';
// https://vitejs.dev/config/ // https://vitejs.dev/config/
export default defineConfig({ export default defineConfig({
plugins: [tsconfigPaths(), react()], plugins: [tsconfigPaths(), react(), nodePolyfills({ protocolImports: true })],
optimizeDeps: {
esbuildOptions: {
// Node.js global to browser globalThis
define: {
global: 'globalThis',
},
// Enable esbuild polyfill plugins
plugins: [
EslintGlobalsPolyfills({
buffer: true,
process: true,
}),
EslintModulePolyfills(),
],
},
},
build: {
rollupOptions: {
plugins: [
// Enable rollup polyfills plugin
// used during production bundling
rollupNodePolyfill(),
],
},
},
}); });

File diff suppressed because it is too large Load Diff