Skip to content

Commit 51849f9

Browse files
committed
[form] Setup dev server
1 parent 00be16c commit 51849f9

File tree

6 files changed

+43
-1
lines changed

6 files changed

+43
-1
lines changed

mkfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ cfw/:
3333

3434
f/:
3535
pushd packages/form
36+
d:
37+
pnpm run dev
3638
b:
3739
pnpm run build
3840
c:

packages/form/index.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!doctype html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>SJSF</title>
8+
</head>
9+
10+
<body>
11+
<div id="app"></div>
12+
<script type="module" src="/src/app.ts"></script>
13+
</body>
14+
15+
</html>

packages/form/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"files": [
1313
"dist",
1414
"LICENSE-APACHE",
15+
"!app.*",
1516
"!dist/**/*.test.*",
1617
"!dist/**/*.spec.*"
1718
],
@@ -26,6 +27,7 @@
2627
"bugs": "https://github.com/x0k/svelte-jsonschema-form/issues",
2728
"homepage": "https://x0k.github.io/svelte-jsonschema-form/",
2829
"scripts": {
30+
"dev": "vite",
2931
"test": "vitest run --exclude '.svelte-kit/**'",
3032
"build": "svelte-package && publint",
3133
"check": "svelte-check --tsconfig ./tsconfig.json"

packages/form/src/app.svelte

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<script lang="ts">
2+
import { Form2, type Schema } from "./form/index.js";
3+
import { theme } from "./basic-theme/index.js";
4+
import { translation } from "./translations/en.js";
5+
import { createValidator } from "./fake-validator.js";
6+
7+
const schema: Schema = {
8+
type: 'string'
9+
};
10+
11+
const validator = createValidator();
12+
</script>
13+
14+
<Form2 {...theme} {schema} {translation} {validator} />

packages/form/src/app.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { mount } from "svelte";
2+
3+
import App from "./app.svelte";
4+
5+
const target = document.getElementById("app");
6+
7+
export default mount(App, { target: target! });

packages/form/vite.config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ export default defineConfig({
99
test: {},
1010
plugins: [svelte()],
1111
resolve: {
12-
conditions: process.env.VITEST ? ["browser"] : [],
12+
conditions: process.env.VITEST
13+
? ["browser"]
14+
: ["module", "browser", "development|production"],
1315
alias: {
1416
"@": resolve(__dirname, "src"),
1517
},

0 commit comments

Comments
 (0)