Skip to content

Commit 7ffc9d6

Browse files
init sandbox preview with vite
1 parent 674aeea commit 7ffc9d6

File tree

7 files changed

+978
-0
lines changed

7 files changed

+978
-0
lines changed

sandbox/README.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Web preview for source code
2+
3+
## ES Preview with Vite
4+
5+
- Go to Directory: [`preview/es`](./es/)
6+
7+
## Flutter Preview with Flutter Daemon ([gridaco/flutter](https://github.com/gridaco/flutter))
8+
9+
- Go to Repository: [gridaco/flutter](https://github.com/gridaco/flutter)
10+
11+
## Testing & Capabilities
12+
13+
- .env loading
14+
- monorepo
15+
- nextjs

sandbox/demos/react/src/App.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const App: React.FC = () => {
55
return (
66
<div>
77
<h1>Hello, world!</h1>
8+
<p>Test component for vite</p>
89
</div>
910
);
1011
};

sandbox/package.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "@scenes/sandbox-daemon",
3+
"version": "0.0.0",
4+
"author": "Grida Inc.",
5+
"homepage": "https://github.com/gridaco/code",
6+
"scripts": {
7+
"build": "tsup",
8+
"dev": "tsup --watch"
9+
},
10+
"dependencies": {
11+
"vite": "^4.3.8"
12+
},
13+
"devDependencies": {
14+
"@types/node": "^20.2.3",
15+
"ts-node": "^10.9.1",
16+
"tsup": "^6.7.0",
17+
"typescript": "^5.0.4"
18+
}
19+
}

sandbox/src/index.ts

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import path from "path";
2+
import { createServer } from "vite";
3+
4+
async function main({ root }: { root: string }) {
5+
const s = await createServer({
6+
configFile: false,
7+
root: root,
8+
base: "/s/",
9+
// server: {
10+
// middlewareMode: true,
11+
// },
12+
});
13+
14+
// file change
15+
s.watcher.on("change", (file) => {
16+
console.log("change", file);
17+
});
18+
19+
s.listen();
20+
}
21+
22+
const root = path.join(__dirname, "../demos/react");
23+
console.log("running", root, "with vite");
24+
main({
25+
root: root,
26+
});

sandbox/tsconfig.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es2020",
4+
"module": "esnext",
5+
"moduleResolution": "node",
6+
"esModuleInterop": true
7+
},
8+
"include": ["src"],
9+
"exclude": ["node_modules"]
10+
}

sandbox/tsup.config.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { defineConfig } from "tsup";
2+
3+
export default defineConfig({
4+
entry: ["src/index.ts"],
5+
splitting: false,
6+
sourcemap: true,
7+
clean: true,
8+
});

0 commit comments

Comments
 (0)