-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add demo build and fix basic dev mode
- Loading branch information
Showing
7 changed files
with
131 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* @file Build extension pages demonstration using the Vite JavaScript API | ||
* @see {@link https://vitejs.dev/guide/api-javascript.html JavaScript API} | ||
*/ | ||
|
||
import { build } from "vite"; | ||
import { svelte } from "@sveltejs/vite-plugin-svelte"; | ||
import { cp, emptyBuildDir, rootDir } from "./utils.js"; | ||
|
||
/** | ||
* Define default vite config options | ||
* Disable auto resolving {@link vite.config.js} | ||
* @see {@link https://vitejs.dev/config/ Config} | ||
* @see {@link https://vitejs.dev/guide/api-javascript.html#inlineconfig InlineConfig} | ||
* @type {import("vite").InlineConfig} | ||
*/ | ||
const defineConfig = { | ||
configFile: false, | ||
envFile: false, | ||
root: await rootDir(), | ||
base: "./", | ||
mode: "development", | ||
define: { | ||
"import.meta.env.BROWSER": JSON.stringify("Safari"), | ||
"import.meta.env.NATIVE_APP": JSON.stringify("app"), | ||
"import.meta.env.SAFARI_PLATFORM": JSON.stringify( | ||
process.env.SAFARI_PLATFORM, | ||
), | ||
"import.meta.env.EXT_DEMO_BUILD": JSON.stringify(true), | ||
}, | ||
}; | ||
|
||
/** | ||
* Empty resources directory | ||
* Copy public static assets | ||
*/ | ||
await emptyBuildDir("dist"); | ||
cp("public/ext/shared", "dist"); | ||
|
||
/** Build shared modules */ | ||
build({ | ||
...defineConfig, | ||
plugins: [svelte()], | ||
publicDir: "public/ext/vendor/", | ||
build: { | ||
outDir: `dist/`, | ||
emptyOutDir: false, | ||
rollupOptions: { | ||
input: ["entry-ext-action-popup.html", "entry-ext-extension-page.html"], | ||
}, | ||
target: "esnext", // top-level await | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* @file Preview App WebView resources using the Vite JavaScript API | ||
* @see {@link https://vitejs.dev/guide/api-javascript.html JavaScript API} | ||
*/ | ||
|
||
import { preview } from "vite"; | ||
|
||
/** | ||
* Define default vite config options | ||
* Disable auto resolving {@link vite.config.js} | ||
* @see {@link https://vitejs.dev/config/ Config} | ||
* @see {@link https://vitejs.dev/guide/api-javascript.html#inlineconfig configFile} | ||
* @type {import("vite").InlineConfig} | ||
*/ | ||
const defineConfig = { | ||
base: "./", | ||
configFile: false, | ||
}; | ||
|
||
/** | ||
* Preview App-Shared WebView resources from xcode dist | ||
*/ | ||
(async () => { | ||
const previewServer = await preview({ | ||
...defineConfig, | ||
preview: { | ||
// port: 4173, | ||
open: "entry-ext-extension-page.html", | ||
}, | ||
build: { | ||
outDir: "dist/", | ||
}, | ||
}); | ||
previewServer.printUrls(); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters