@datf/sveltekit-github-pages-config-dockerized 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,17 @@
1
+ # [sv](https://svelte.dev/docs/cli/overview) community add-on: [@datf/sveltekit-github-pages-config-dockerized](https://github.com/@datf/sveltekit-github-pages-config-dockerized)
2
+
3
+ > [!IMPORTANT]
4
+ > Svelte maintainers have not reviewed community add-ons for malicious code. Use at your discretion
5
+
6
+ ## Usage
7
+
8
+ To install the add-on, run:
9
+
10
+ ```shell
11
+ npx sv add @datf/sveltekit-github-pages-config-dockerized
12
+ ```
13
+
14
+ ## What you get
15
+
16
+ - Project settings for a svelte SPA that runs on GitHub Pages
17
+ - Settings to run it containerized locally
package/dist/index.mjs ADDED
@@ -0,0 +1,54 @@
1
+ import { transforms } from "./sv-utils.mjs";
2
+ import { defineAddon, defineAddonOptions } from "sv";
3
+ var src_default = defineAddon({
4
+ id: "@datf/sveltekit-github-pages-config-dockerized",
5
+ options: defineAddonOptions().build(),
6
+ setup: ({ isKit, unsupported }) => {
7
+ if (!isKit) unsupported("Requires SvelteKit");
8
+ },
9
+ run: ({ sv, file, language }) => {
10
+ sv.file("svelte.config.js", transforms.script(({ ast, js }) => {
11
+ js.imports.addNamed(ast, {
12
+ imports: ["vitePreprocess"],
13
+ from: "@sveltejs/vite-plugin-svelte"
14
+ });
15
+ const { value: config } = js.exports.createDefault(ast);
16
+ js.object.overrideProperties(config, {
17
+ preprocess: js.functions.createCall({
18
+ name: "vitePreprocess",
19
+ args: []
20
+ }),
21
+ compilerOptions: js.object.create({ css: "injected" }),
22
+ output: js.object.create({ bundleStrategy: "inline" }),
23
+ kit: js.object.create({ adapter: js.common.parseExpression(`adapter({
24
+ fallback: '404.html',
25
+ pages: 'build',
26
+ assets: 'build',
27
+ precompress: false,
28
+ strict: true
29
+ })`) }),
30
+ paths: js.object.create({ base: js.common.parseExpression(`process.argv.includes('dev') ? '' : process.env.BASE_PATH`) })
31
+ });
32
+ }));
33
+ sv.file(file.viteConfig, transforms.script(({ ast, js }) => {
34
+ const viteConfig = js.vite.getConfig(ast);
35
+ js.object.overrideProperties(viteConfig, {
36
+ server: js.object.create({
37
+ host: "0.0.0.0",
38
+ port: 5173,
39
+ watch: { usePolling: true },
40
+ hmr: {
41
+ host: "localhost",
42
+ port: 5173
43
+ }
44
+ }),
45
+ preview: js.object.create({
46
+ host: "0.0.0.0",
47
+ port: 4173
48
+ })
49
+ });
50
+ }));
51
+ }
52
+ });
53
+ //#endregion
54
+ export { src_default as default };