histoire 0.2.3 → 0.3.0
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/dist/client/app/App.vue +9 -4
- package/dist/client/app/codegen/const.d.ts +1 -0
- package/dist/client/app/codegen/const.js +3 -0
- package/dist/client/app/codegen/vue3.js +82 -21
- package/dist/client/app/components/app/AppHeader.vue +2 -2
- package/dist/client/app/components/app/Breadcrumb.vue +1 -1
- package/dist/client/app/components/base/BaseEmpty.vue +17 -1
- package/dist/client/app/components/base/BaseListItemLink.vue +1 -1
- package/dist/client/app/components/base/BaseTab.vue +1 -1
- package/dist/client/app/components/exposed/Story.vue +22 -1
- package/dist/client/app/components/exposed/Variant.vue +13 -1
- package/dist/client/app/components/sandbox/SandboxVue3.vue +6 -4
- package/dist/client/app/components/sandbox/lib.js +2 -1
- package/dist/client/app/components/search/SearchItem.vue +1 -0
- package/dist/client/app/components/search/SearchLoading.vue +16 -0
- package/dist/client/app/components/search/SearchModal.vue +12 -148
- package/dist/client/app/components/search/SearchPane.vue +210 -0
- package/dist/client/app/components/search/search-data.d.ts +2 -0
- package/dist/client/app/components/search/search-data.js +7 -0
- package/dist/client/app/components/story/StoryControls.vue +5 -0
- package/dist/client/app/components/story/StoryDocs.vue +18 -11
- package/dist/client/app/components/story/StoryEvent.vue +53 -0
- package/dist/client/app/components/story/StoryEvents.vue +45 -0
- package/dist/client/app/components/story/StoryResponsivePreview.vue +41 -8
- package/dist/client/app/components/story/StorySidePanel.vue +28 -3
- package/dist/client/app/components/story/StorySourceCode.vue +24 -14
- package/dist/client/app/components/story/StoryView.vue +16 -2
- package/dist/client/app/components/story/toolbar/StoryVariantNewTab.vue +1 -1
- package/dist/client/app/components/tree/StoryGroup.vue +75 -0
- package/dist/client/app/components/{story → tree}/StoryList.vue +8 -2
- package/{src/client/app/components/story → dist/client/app/components/tree}/StoryListFolder.vue +10 -8
- package/{src/client/app/components/story → dist/client/app/components/tree}/StoryListItem.vue +7 -4
- package/dist/client/app/router.d.ts +1 -0
- package/dist/client/app/router.js +3 -1
- package/dist/client/app/sandbox.js +11 -1
- package/dist/client/app/stores/events.d.ts +29 -0
- package/dist/client/app/stores/events.js +25 -0
- package/dist/client/app/stores/folder.d.ts +10 -0
- package/dist/client/app/stores/folder.js +47 -0
- package/dist/client/app/stores/story.d.ts +20 -8
- package/dist/client/app/stores/story.js +20 -28
- package/dist/client/app/style/floating-vue.pcss +3 -1
- package/dist/client/app/style/main.pcss +5 -0
- package/dist/client/app/style/sandbox.css +2 -0
- package/dist/client/app/types.d.ts +9 -1
- package/dist/client/app/util/const.d.ts +1 -0
- package/dist/client/app/util/const.js +1 -0
- package/dist/client/app/util/events.d.ts +1 -0
- package/dist/client/app/util/events.js +31 -0
- package/dist/client/app/util/mapping.js +2 -2
- package/dist/client/index.d.ts +2 -1
- package/dist/client/index.js +2 -1
- package/dist/client/server/Story.server.vue +21 -4
- package/dist/node/alias.d.ts +2 -1
- package/dist/node/alias.js +3 -2
- package/dist/node/build.js +74 -21
- package/dist/node/builtin-plugins/tailwind-tokens.d.ts +5 -0
- package/dist/node/builtin-plugins/tailwind-tokens.js +510 -0
- package/dist/node/collect/index.js +5 -3
- package/dist/node/commands/preview.js +4 -25
- package/dist/node/config.d.ts +111 -5
- package/dist/node/config.js +40 -23
- package/dist/node/context.d.ts +3 -3
- package/dist/node/context.js +1 -1
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.js +1 -0
- package/dist/node/load.d.ts +12 -0
- package/dist/node/load.js +42 -0
- package/dist/node/plugin.d.ts +67 -11
- package/dist/node/plugin.js +42 -245
- package/dist/node/preview.d.ts +8 -0
- package/dist/node/preview.js +41 -0
- package/dist/node/search.d.ts +2 -0
- package/dist/node/search.js +68 -0
- package/dist/node/server.js +43 -21
- package/dist/node/stories.d.ts +2 -0
- package/dist/node/stories.js +9 -4
- package/dist/node/tree.d.ts +16 -12
- package/dist/node/tree.js +45 -5
- package/dist/node/types.d.ts +11 -0
- package/dist/node/util/find-up.d.ts +1 -0
- package/dist/node/util/find-up.js +20 -0
- package/dist/node/vite.d.ts +13 -0
- package/dist/node/vite.js +278 -0
- package/dist/style.css +179 -36
- package/package.json +5 -3
- package/scripts/copy.mjs +2 -1
- package/src/client/app/App.vue +9 -4
- package/src/client/app/codegen/const.ts +3 -0
- package/src/client/app/codegen/vue3.ts +80 -22
- package/src/client/app/components/app/AppHeader.vue +2 -2
- package/src/client/app/components/app/Breadcrumb.vue +1 -1
- package/src/client/app/components/base/BaseEmpty.vue +17 -1
- package/src/client/app/components/base/BaseListItemLink.vue +1 -1
- package/src/client/app/components/base/BaseTab.vue +1 -1
- package/src/client/app/components/exposed/Story.vue +22 -1
- package/src/client/app/components/exposed/Variant.vue +13 -1
- package/src/client/app/components/sandbox/SandboxVue3.vue +6 -4
- package/src/client/app/components/sandbox/lib.ts +3 -1
- package/src/client/app/components/search/SearchItem.vue +1 -0
- package/src/client/app/components/search/SearchLoading.vue +16 -0
- package/src/client/app/components/search/SearchModal.vue +12 -148
- package/src/client/app/components/search/SearchPane.vue +210 -0
- package/src/client/app/components/search/search-data.ts +9 -0
- package/src/client/app/components/story/StoryControls.vue +5 -0
- package/src/client/app/components/story/StoryDocs.vue +18 -11
- package/src/client/app/components/story/StoryEvent.vue +53 -0
- package/src/client/app/components/story/StoryEvents.vue +45 -0
- package/src/client/app/components/story/StoryResponsivePreview.vue +41 -8
- package/src/client/app/components/story/StorySidePanel.vue +28 -3
- package/src/client/app/components/story/StorySourceCode.vue +24 -14
- package/src/client/app/components/story/StoryView.vue +16 -2
- package/src/client/app/components/story/toolbar/StoryVariantNewTab.vue +1 -1
- package/src/client/app/components/tree/StoryGroup.vue +75 -0
- package/src/client/app/components/{story → tree}/StoryList.vue +8 -2
- package/{dist/client/app/components/story → src/client/app/components/tree}/StoryListFolder.vue +10 -8
- package/{dist/client/app/components/story → src/client/app/components/tree}/StoryListItem.vue +7 -4
- package/src/client/app/router.ts +4 -1
- package/src/client/app/sandbox.ts +12 -2
- package/src/client/app/stores/events.ts +36 -0
- package/src/client/app/stores/folder.ts +59 -0
- package/src/client/app/stores/story.ts +20 -35
- package/src/client/app/style/floating-vue.pcss +3 -1
- package/src/client/app/style/main.pcss +5 -0
- package/src/client/app/style/sandbox.css +2 -0
- package/src/client/app/types.ts +10 -1
- package/src/client/app/util/const.ts +1 -0
- package/src/client/app/util/events.ts +30 -0
- package/src/client/app/util/mapping.ts +2 -2
- package/src/client/index.ts +2 -1
- package/src/client/server/Story.server.vue +21 -4
- package/src/node/alias.ts +4 -2
- package/src/node/build.ts +86 -21
- package/src/node/builtin-plugins/tailwind-tokens.ts +521 -0
- package/src/node/collect/index.ts +6 -4
- package/src/node/commands/preview.ts +4 -33
- package/src/node/config.ts +62 -29
- package/src/node/context.ts +3 -3
- package/src/node/index.ts +1 -0
- package/src/node/load.ts +63 -0
- package/src/node/plugin.ts +75 -252
- package/src/node/preview.ts +56 -0
- package/src/node/search.ts +75 -0
- package/src/node/server.ts +49 -23
- package/src/node/stories.ts +9 -4
- package/src/node/tree.spec.ts +35 -17
- package/src/node/tree.ts +64 -10
- package/src/node/types.ts +12 -0
- package/src/node/util/find-up.ts +24 -0
- package/src/node/vite.ts +296 -0
- package/tailwind.config.cjs +1 -0
- package/tsconfig.json +2 -0
- package/dist/client/app/codegen/serialize-js.ts +0 -119
- package/dist/client/app/codegen/util.ts +0 -79
- package/dist/client/app/codegen/vue3.ts +0 -276
- package/dist/client/app/components/sandbox/lib.ts +0 -8
- package/dist/client/app/global-components.ts +0 -13
- package/dist/client/app/index.ts +0 -28
- package/dist/client/app/router.ts +0 -17
- package/dist/client/app/sandbox.ts +0 -94
- package/dist/client/app/stores/preview-settings.ts +0 -17
- package/dist/client/app/stores/story.ts +0 -62
- package/dist/client/app/types.ts +0 -70
- package/dist/client/app/util/config.ts +0 -6
- package/dist/client/app/util/const.ts +0 -3
- package/dist/client/app/util/dark.ts +0 -4
- package/dist/client/app/util/env.ts +0 -1
- package/dist/client/app/util/keyboard.ts +0 -99
- package/dist/client/app/util/mapping.ts +0 -48
- package/dist/client/app/util/preview-settings.ts +0 -8
- package/dist/client/app/util/reactivity.ts +0 -22
- package/dist/client/app/util/responsive.ts +0 -3
- package/dist/client/app/util/scroll.ts +0 -31
- package/dist/client/app/util/tooltip.ts +0 -13
- package/dist/client/app/util/variant.ts +0 -20
- package/dist/client/index.ts +0 -12
- package/dist/client/server/index.ts +0 -32
- package/dist/client/shim.d.ts +0 -5
|
@@ -18,7 +18,7 @@ export function mapFile(file, existingFile) {
|
|
|
18
18
|
for (const key in existingVariant) {
|
|
19
19
|
if (typeof existingVariant[key] !== 'undefined') {
|
|
20
20
|
if (key === 'state') {
|
|
21
|
-
|
|
21
|
+
variant.state = existingVariant.state;
|
|
22
22
|
continue;
|
|
23
23
|
}
|
|
24
24
|
variant[key] = existingVariant[key];
|
|
@@ -35,7 +35,7 @@ export function mapFile(file, existingFile) {
|
|
|
35
35
|
export function mapVariant(variant) {
|
|
36
36
|
return {
|
|
37
37
|
...variant,
|
|
38
|
-
state:
|
|
38
|
+
state: null,
|
|
39
39
|
initState: null,
|
|
40
40
|
slots: () => ({}),
|
|
41
41
|
previewReady: false,
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { App } from 'vue';
|
|
2
2
|
import type { Story, Variant } from './app/types.js';
|
|
3
|
+
export { hstEvent } from './app/util/events';
|
|
3
4
|
export declare type Vue3StorySetupHandler = (payload: {
|
|
4
5
|
app: App;
|
|
5
6
|
story: Story;
|
|
6
7
|
variant: Variant;
|
|
7
8
|
}) => Promise<void> | void;
|
|
8
|
-
export declare function
|
|
9
|
+
export declare function defineSetupVue3(handler: Vue3StorySetupHandler): Vue3StorySetupHandler;
|
package/dist/client/index.js
CHANGED
|
@@ -8,7 +8,17 @@ export default defineComponent({
|
|
|
8
8
|
props: {
|
|
9
9
|
title: {
|
|
10
10
|
type: String,
|
|
11
|
-
|
|
11
|
+
default: null,
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
id: {
|
|
15
|
+
type: String,
|
|
16
|
+
default: null,
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
group: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: null,
|
|
12
22
|
},
|
|
13
23
|
|
|
14
24
|
layout: {
|
|
@@ -25,6 +35,11 @@ export default defineComponent({
|
|
|
25
35
|
type: String,
|
|
26
36
|
default: null,
|
|
27
37
|
},
|
|
38
|
+
|
|
39
|
+
docsOnly: {
|
|
40
|
+
type: Boolean,
|
|
41
|
+
default: false,
|
|
42
|
+
},
|
|
28
43
|
},
|
|
29
44
|
|
|
30
45
|
setup (props) {
|
|
@@ -35,11 +50,13 @@ export default defineComponent({
|
|
|
35
50
|
// Story
|
|
36
51
|
|
|
37
52
|
const story: Story = {
|
|
38
|
-
id: attrs.data.id,
|
|
39
|
-
title: props.title,
|
|
53
|
+
id: props.id ?? attrs.data.id,
|
|
54
|
+
title: props.title ?? attrs.data.fileName,
|
|
55
|
+
group: props.group,
|
|
40
56
|
layout: props.layout,
|
|
41
57
|
icon: props.icon,
|
|
42
58
|
iconColor: props.iconColor,
|
|
59
|
+
docsOnly: props.docsOnly,
|
|
43
60
|
variants: [],
|
|
44
61
|
}
|
|
45
62
|
const addStory = inject('addStory', null)
|
|
@@ -70,7 +87,7 @@ export default defineComponent({
|
|
|
70
87
|
render () {
|
|
71
88
|
let suppressError = false
|
|
72
89
|
try {
|
|
73
|
-
return this.$slots.default({
|
|
90
|
+
return this.$slots.default?.({
|
|
74
91
|
get state () {
|
|
75
92
|
// No variant tags
|
|
76
93
|
suppressError = true
|
package/dist/node/alias.d.ts
CHANGED
package/dist/node/alias.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { dirname, join } from 'pathe';
|
|
2
2
|
import { fileURLToPath } from 'url';
|
|
3
3
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
4
|
-
export const
|
|
5
|
-
export const APP_PATH = join(
|
|
4
|
+
export const DIST_PATH = join(__dirname, '../');
|
|
5
|
+
export const APP_PATH = join(DIST_PATH, 'client', 'app');
|
|
6
|
+
export const TEMP_PATH = join(process.cwd(), 'node_modules', '.histoire');
|
package/dist/node/build.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { join } from 'pathe';
|
|
2
|
-
import { build as viteBuild, createServer as createViteServer } from 'vite';
|
|
2
|
+
import { build as viteBuild, createServer as createViteServer, resolveConfig as resolveViteConfig } from 'vite';
|
|
3
3
|
import fs from 'fs-extra';
|
|
4
4
|
import { lookup as lookupMime } from 'mrmime';
|
|
5
5
|
import pc from 'picocolors';
|
|
6
6
|
import { performance } from 'perf_hooks';
|
|
7
7
|
import { APP_PATH } from './alias.js';
|
|
8
|
-
import { createVitePlugins } from './
|
|
8
|
+
import { createVitePlugins } from './vite.js';
|
|
9
9
|
import { findAllStories } from './stories.js';
|
|
10
10
|
import { useCollectStories } from './collect/index.js';
|
|
11
|
+
import { BuildPluginApi } from './plugin.js';
|
|
12
|
+
import { useModuleLoader } from './load.js';
|
|
13
|
+
import { startPreview } from './preview.js';
|
|
11
14
|
const PRELOAD_MODULES = [
|
|
12
15
|
'vendor',
|
|
13
16
|
];
|
|
@@ -19,11 +22,25 @@ const PREFETCHED_MODULES = [
|
|
|
19
22
|
export async function build(ctx) {
|
|
20
23
|
const startTime = performance.now();
|
|
21
24
|
await findAllStories(ctx);
|
|
22
|
-
// Collect story data
|
|
23
25
|
const server = await createViteServer({
|
|
24
26
|
plugins: await createVitePlugins(ctx),
|
|
25
27
|
});
|
|
26
28
|
await server.pluginContainer.buildStart({});
|
|
29
|
+
const moduleLoader = useModuleLoader({
|
|
30
|
+
server,
|
|
31
|
+
throws: true,
|
|
32
|
+
});
|
|
33
|
+
const buildEndCallbacks = [];
|
|
34
|
+
const previewStoryCallbacks = [];
|
|
35
|
+
for (const plugin of ctx.config.plugins) {
|
|
36
|
+
if (plugin.onBuild) {
|
|
37
|
+
const api = new BuildPluginApi(ctx, plugin, moduleLoader);
|
|
38
|
+
await plugin.onBuild(api);
|
|
39
|
+
buildEndCallbacks.push(...api.buildEndCallbacks);
|
|
40
|
+
previewStoryCallbacks.push(...api.previewStoryCallbacks);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
// Collect story data
|
|
27
44
|
const { executeStoryFile, destroy: destroyCollectStories } = useCollectStories({
|
|
28
45
|
server,
|
|
29
46
|
throws: true,
|
|
@@ -31,7 +48,6 @@ export async function build(ctx) {
|
|
|
31
48
|
for (const storyFile of ctx.storyFiles) {
|
|
32
49
|
await executeStoryFile(storyFile);
|
|
33
50
|
}
|
|
34
|
-
await server.close();
|
|
35
51
|
await destroyCollectStories();
|
|
36
52
|
const storyCount = ctx.storyFiles.reduce((sum, file) => sum + (file.story?.variants.length ? 1 : 0), 0);
|
|
37
53
|
const variantCount = ctx.storyFiles.reduce((sum, file) => sum + (file.story?.variants.length ?? 0), 0);
|
|
@@ -41,8 +57,8 @@ export async function build(ctx) {
|
|
|
41
57
|
build: {
|
|
42
58
|
rollupOptions: {
|
|
43
59
|
input: [
|
|
44
|
-
join(APP_PATH, 'index.
|
|
45
|
-
join(APP_PATH, 'sandbox.
|
|
60
|
+
join(APP_PATH, 'index.js'),
|
|
61
|
+
join(APP_PATH, 'sandbox.js'),
|
|
46
62
|
],
|
|
47
63
|
output: {
|
|
48
64
|
manualChunks(id) {
|
|
@@ -55,49 +71,86 @@ export async function build(ctx) {
|
|
|
55
71
|
outDir: ctx.config.outDir,
|
|
56
72
|
emptyOutDir: true,
|
|
57
73
|
cssCodeSplit: false,
|
|
74
|
+
minify: false,
|
|
58
75
|
},
|
|
59
76
|
});
|
|
60
77
|
const result = Array.isArray(results) ? results[0] : results;
|
|
78
|
+
const resolvedViteConfig = await resolveViteConfig({
|
|
79
|
+
plugins: await createVitePlugins(ctx),
|
|
80
|
+
}, 'build');
|
|
61
81
|
const styleOutput = result.output.find(o => o.name === 'style.css' && o.type === 'asset');
|
|
62
82
|
// Preload
|
|
63
83
|
const preloadOutputs = result.output.filter(o => PRELOAD_MODULES.includes(o.name) && o.type === 'chunk');
|
|
64
|
-
const preloadHtml = generateScriptLinks(preloadOutputs.map(o => o.fileName), 'preload');
|
|
84
|
+
const preloadHtml = generateScriptLinks(preloadOutputs.map(o => o.fileName), 'preload', ctx, resolvedViteConfig);
|
|
65
85
|
// Prefetch
|
|
66
86
|
const prefetchOutputs = result.output.filter(o => PREFETCHED_MODULES.includes(o.name) && o.type === 'chunk');
|
|
67
|
-
const prefetchHtml = generateScriptLinks(prefetchOutputs.map(o => o.fileName), 'prefetch');
|
|
87
|
+
const prefetchHtml = generateScriptLinks(prefetchOutputs.map(o => o.fileName), 'prefetch', ctx, resolvedViteConfig);
|
|
68
88
|
// Index
|
|
69
89
|
const indexOutput = result.output.find(o => o.name === 'index' && o.type === 'chunk');
|
|
70
|
-
|
|
90
|
+
const indexHtml = generateEntryHtml(indexOutput.fileName, styleOutput.fileName, {
|
|
71
91
|
HEAD: `${preloadHtml}${prefetchHtml}`,
|
|
72
|
-
}, ctx);
|
|
92
|
+
}, ctx, resolvedViteConfig);
|
|
93
|
+
await writeFile('index.html', indexHtml, ctx);
|
|
73
94
|
// Sandbox
|
|
74
95
|
const sandboxOutput = result.output.find(o => o.name === 'sandbox' && o.type === 'chunk');
|
|
75
|
-
|
|
96
|
+
const sandboxHtml = generateEntryHtml(sandboxOutput.fileName, styleOutput.fileName, {}, ctx, resolvedViteConfig);
|
|
97
|
+
await writeFile('__sandbox.html', sandboxHtml, ctx);
|
|
76
98
|
const duration = performance.now() - startTime;
|
|
77
99
|
if (emptyStoryCount) {
|
|
78
100
|
console.warn(pc.yellow(`⚠️ ${emptyStoryCount} empty story file`));
|
|
79
101
|
}
|
|
80
102
|
console.log(pc.green(`✅ Built ${storyCount} stories (${variantCount} variants) in ${Math.round(duration / 1000 * 100) / 100}s`));
|
|
103
|
+
// Render
|
|
104
|
+
if (previewStoryCallbacks.length) {
|
|
105
|
+
const { baseUrl, close } = await startPreview(resolvedViteConfig, null, ctx);
|
|
106
|
+
for (const storyFile of ctx.storyFiles) {
|
|
107
|
+
const story = storyFile.story;
|
|
108
|
+
for (const variant of story.variants) {
|
|
109
|
+
const query = new URLSearchParams();
|
|
110
|
+
query.append('storyId', story.id);
|
|
111
|
+
query.append('variantId', variant.id);
|
|
112
|
+
const url = `${baseUrl}__sandbox?${query.toString()}`;
|
|
113
|
+
for (const fn of previewStoryCallbacks) {
|
|
114
|
+
await fn({
|
|
115
|
+
file: storyFile.path,
|
|
116
|
+
story,
|
|
117
|
+
variant,
|
|
118
|
+
url,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
await close();
|
|
124
|
+
}
|
|
125
|
+
await server.close();
|
|
126
|
+
for (const fn of buildEndCallbacks) {
|
|
127
|
+
await fn();
|
|
128
|
+
}
|
|
81
129
|
}
|
|
82
|
-
|
|
83
|
-
|
|
130
|
+
function generateBaseHtml(head, body, ctx) {
|
|
131
|
+
return `<!DOCTYPE html>
|
|
84
132
|
<html>
|
|
85
133
|
<head>
|
|
86
134
|
<title>${ctx.config.theme.title}</title>
|
|
87
135
|
<meta charset="utf-8">
|
|
88
136
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
89
137
|
<meta name="description" content="">
|
|
90
|
-
|
|
91
|
-
${ctx.config.theme?.favicon ? `<link rel="icon" type="${lookupMime(ctx.config.theme.favicon)}" href="${ctx.config.theme.favicon}"/>` : ''}
|
|
92
|
-
${variables.HEAD ?? ''}
|
|
138
|
+
${head}
|
|
93
139
|
</head>
|
|
94
140
|
<body>
|
|
95
|
-
|
|
96
|
-
<script type="module" src="/${jsEntryFile}"></script>
|
|
141
|
+
${body}
|
|
97
142
|
</body>
|
|
98
143
|
</html>`;
|
|
99
|
-
await fs.writeFile(join(ctx.config.outDir, htmlFileName), code, 'utf8');
|
|
100
144
|
}
|
|
101
|
-
function
|
|
102
|
-
return
|
|
145
|
+
function generateEntryHtml(jsEntryFile, cssEntryFile, variables, ctx, resolvedViteConfig) {
|
|
146
|
+
return generateBaseHtml(`<link rel="stylesheet" href="${resolvedViteConfig.base}${cssEntryFile}">
|
|
147
|
+
${ctx.config.theme?.favicon ? `<link rel="icon" type="${lookupMime(ctx.config.theme.favicon)}" href="${ctx.config.theme.favicon}"/>` : ''}
|
|
148
|
+
${variables.HEAD ?? ''}`, `<div id="app"></div>
|
|
149
|
+
<script type="module" src="${resolvedViteConfig.base}${jsEntryFile}"></script>`, ctx);
|
|
150
|
+
}
|
|
151
|
+
async function writeFile(fileName, content, ctx) {
|
|
152
|
+
await fs.writeFile(join(ctx.config.outDir, fileName), content, 'utf8');
|
|
153
|
+
}
|
|
154
|
+
function generateScriptLinks(prefetchScripts, rel, ctx, resolvedViteConfig) {
|
|
155
|
+
return prefetchScripts.map(s => `<link rel="${rel}" href="${resolvedViteConfig.base}${s}" as="script" crossOrigin="anonymous">`).join('');
|
|
103
156
|
}
|