Skip to content

Commit

Permalink
Build example app with Vite
Browse files Browse the repository at this point in the history
  • Loading branch information
smikhalevski committed Sep 5, 2024
1 parent 1776762 commit b3be232
Show file tree
Hide file tree
Showing 7 changed files with 171 additions and 69 deletions.
118 changes: 116 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"esModuleInterop": true,
"isolatedModules": true,
"strict": true,
"target": "ES6",
"target": "ES5",
"module": "ESNext",
"lib": [
"DOM",
Expand Down
56 changes: 0 additions & 56 deletions web/example/esbuild.config.mjs

This file was deleted.

7 changes: 1 addition & 6 deletions web/example/jointly.config.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
[
{
"label": "esbuild",
"command": "node",
"args": [
"esbuild.config.mjs",
"--watch"
]
"command": "vite"
},
{
"command": "tsc",
Expand Down
8 changes: 4 additions & 4 deletions web/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
"private": true,
"type": "module",
"scripts": {
"build": "tsc && node esbuild.config.mjs",
"watch": "jointly",
"build": "tsc && vite build",
"start": "jointly",
"clean": "rimraf dist"
},
"devDependencies": {
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"esbuild": "^0.21.5",
"jointly": "^0.0.2",
"tslib": "^2.6.3",
"typescript": "^5.4.5"
"typescript": "^5.4.5",
"vite": "^5.4.3"
},
"dependencies": {
"@racehorse/react": "^1.2.1",
Expand Down
11 changes: 11 additions & 0 deletions web/example/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Racehorse</title>
</head>
<body>
<script src="./index.tsx" type="module"></script>
</body>
</html>
38 changes: 38 additions & 0 deletions web/example/vite.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { defineConfig } from 'vite';
import { execSync } from 'child_process';
import path from 'path';

const outputPath = path.resolve('dist');
const archivePath = path.join(outputPath, 'bundle.zip');

export default defineConfig({
root: './src',
build: {
minify: true,
assetsDir: '.',
outDir: outputPath,
emptyOutDir: false,
modulePreload: {
polyfill: false,
},
},
resolve: {
preserveSymlinks: true,
},
server: {
port: 10001,
host: '127.0.0.1',
hmr: {
host: '10.0.2.2',
port: 10001,
protocol: 'ws',
},
},
plugins: [
{
closeBundle() {
execSync(`zip -FSr ${archivePath} .`, { cwd: outputPath });
},
},
],
});

0 comments on commit b3be232

Please sign in to comment.