Skip to content

Commit

Permalink
Setup vite for wccd
Browse files Browse the repository at this point in the history
  • Loading branch information
soerenbf committed Oct 18, 2023
1 parent 73b797a commit b8a45ff
Show file tree
Hide file tree
Showing 13 changed files with 1,075 additions and 110 deletions.
4 changes: 2 additions & 2 deletions examples/wCCD/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ FROM ${base_image} AS build
WORKDIR /app
COPY ./package.json ./package.json
COPY ./tsconfig.json ./tsconfig.json
COPY ./esbuild.config.ts ./
COPY ./types ./types
COPY ./index.html ./
COPY ./vite.config.ts ./
COPY ./src ./src

RUN yarn && yarn cache clean
Expand Down
56 changes: 0 additions & 56 deletions examples/wCCD/esbuild.config.ts

This file was deleted.

23 changes: 23 additions & 0 deletions examples/wCCD/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html>

<head>
<style>
body {
background-color: #1e1e1e;
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
}
</style>

<link rel="icon" type="image/x-icon" href="/concordium_favicon.svg" />
<meta charset="utf-8" />
</head>

<body>
<div id="root"></div>
<script src="/src/index.tsx" type="module"></script>
</body>

</html>
21 changes: 9 additions & 12 deletions examples/wCCD/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,20 @@
"react-dom": "^18.1.0"
},
"devDependencies": {
"@craftamap/esbuild-plugin-html": "^0.4.0",
"@types/node": "^18.7.23",
"@types/react": "^18.0.9",
"@types/react-dom": "^18.0.5",
"cross-env": "^7.0.3",
"esbuild": "^0.19.5",
"esbuild-plugin-svgr": "^1.0.1",
"fs": "^0.0.1-security",
"live-server": "^1.2.2",
"@vitejs/plugin-react-swc": "^3.4.0",
"process": "^0.11.10",
"ts-node": "^10.8.0",
"typescript": "^5.2.2"
"typescript": "^5.2.2",
"vite": "^4.5.0",
"vite-plugin-svgr": "^4.1.0",
"vite-plugin-top-level-await": "^1.3.1",
"vite-plugin-wasm": "^3.2.2"
},
"scripts": {
"build": "NETWORK='testnet' node --loader ts-node/esm ./esbuild.config.ts; cp ./src/assets/* ./dist",
"build:prod": "NETWORK='mainnet' node --loader ts-node/esm ./esbuild.config.ts; cp ./src/assets/* ./dist",
"watch": "cross-env WATCH=1 yarn build",
"start": "live-server ./dist"
"build": "tsc && vite build",
"build:prod": "NETWORK='mainnet' vite build",
"start": "vite preview"
}
}
1 change: 1 addition & 0 deletions examples/wCCD/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ body {
line-height: 20px;
letter-spacing: 0;
text-align: left;
margin: 0;
}

.wccd {
Expand Down
19 changes: 0 additions & 19 deletions examples/wCCD/src/index.html

This file was deleted.

4 changes: 2 additions & 2 deletions examples/wCCD/src/wCCD.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import {
WALLET_CONNECT,
} from './constants';

import ArrowIcon from './assets/Arrow.svg';
import RefreshIcon from './assets/Refresh.svg';
import ArrowIcon from './assets/Arrow.svg?react';
import RefreshIcon from './assets/Refresh.svg?react';
import { WalletConnectionTypeButton } from './WalletConnectorTypeButton';

const blackCardStyle = {
Expand Down
17 changes: 13 additions & 4 deletions examples/wCCD/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
{
"compilerOptions": {
"target": "ES2020",
"lib": ["dom", "dom.iterable", "esnext"],
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"downlevelIteration": true,
"baseUrl": ".",
"noEmit": true,
"jsx": "react"
"jsx": "react",
"types": [
"vite-plugin-svgr/client"
]
},
"ts-node": {
"compilerOptions": {
"module": "CommonJS"
}
},
"include": ["./**/*"]
"include": [
"./**/*"
]
}
1 change: 0 additions & 1 deletion examples/wCCD/types/svg.d.ts

This file was deleted.

24 changes: 24 additions & 0 deletions examples/wCCD/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react-swc';
import svgr from 'vite-plugin-svgr';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import wasm from 'vite-plugin-wasm';
import topLevelAwait from 'vite-plugin-top-level-await';

export default defineConfig({
plugins: [
react(),
svgr(),
wasm(),
topLevelAwait(), // For legacy browser compatibility
],
define: {
'process.env.NETWORK': process.env.NETWORK ?? 'testnet',
},
resolve: {
alias: {
'@concordium/rust-bindings': '@concordium/rust-bindings/bundler', // Resolve bundler-specific wasm entrypoints.
},
},
});
Loading

0 comments on commit b8a45ff

Please sign in to comment.