Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add polyfills and plugin checker for Vite (#153) #159

Merged
merged 2 commits into from
Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
],
"homepage": "https://github.com/workbenchapp/solana-workbench-releases",
"devDependencies": {
"@esbuild-plugins/node-globals-polyfill": "^0.1.1",
"@iconify-json/mdi": "^1.1.20",
"@solana/wallet-adapter-wallets": "^0.15.5",
"@solana/web3.js": "^1.41.3",
Expand Down Expand Up @@ -205,6 +206,7 @@
"unplugin-icons": "^0.14.3",
"url-loader": "^4.1.1",
"vite": "^2.9.12",
"vite-plugin-checker": "^0.4.6",
"vite-plugin-fonts": "^0.4.0",
"vite-plugin-inline-css-modules": "^0.0.4",
"vite-plugin-windicss": "^1.8.4",
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import OverlayTrigger from 'react-bootstrap/OverlayTrigger';
import Tooltip from 'react-bootstrap/Tooltip';
import { NavLink, Outlet, Route, Routes } from 'react-router-dom';
import { ToastContainer } from 'react-toastify';
import { logger } from '@/common/globals';
import { logger } from './common/globals';
import 'react-toastify/dist/ReactToastify.css';
import './App.scss';
import { getElectronStorageWallet } from './data/accounts/account';
Expand Down
8 changes: 6 additions & 2 deletions src/renderer/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@ code {
}

.btn {
@apply bg-primary-base p-1 text-contrast py-3 px-4 rounded-md cursor-pointer focus:outline outline-offset-2 outline-2 outline-primary-base;
@apply text-xs bg-primary-base p-1 text-contrast py-2 px-4 rounded-md cursor-pointer focus:outline outline-offset-2 outline-2 outline-primary-base;

&.btn-sm {
@apply text-xs py-2 px-3;
@apply py-2 px-3;
}

&:disabled {
@apply opacity-50 bg-surface-100 cursor-auto;
}
}

Expand Down
22 changes: 22 additions & 0 deletions src/renderer/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { defineConfig } from 'vite';
import ViteFonts from 'vite-plugin-fonts';
import InlineCSSModules from 'vite-plugin-inline-css-modules';
import WindiCSS from 'vite-plugin-windicss';
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill';
import checker from 'vite-plugin-checker';

const PACKAGE_ROOT = __dirname;
/**
Expand All @@ -21,6 +23,20 @@ export default defineConfig({
'@/': `${join(PACKAGE_ROOT, './')}/`,
},
},
optimizeDeps: {
esbuildOptions: {
// Node.js global to browser globalThis
define: {
global: 'globalThis',
},
// Enable esbuild polyfill plugins
plugins: [
NodeGlobalsPolyfillPlugin({
buffer: true,
}),
],
},
},
plugins: [
ViteFonts({
google: {
Expand Down Expand Up @@ -48,6 +64,12 @@ export default defineConfig({
}),
react(),
WindiCSS(),
checker({
typescript: {
root: PACKAGE_ROOT,
tsconfigPath: `./tsconfig.json`,
},
}),
],
base: '',
server: {
Expand Down