1
|
|
-import { Plugin } from 'vite'
|
2
|
|
-import { createHtmlPlugin } from 'vite-plugin-html'
|
|
1
|
+import { HtmlTagDescriptor, Plugin } from 'vite'
|
|
2
|
+// import { createHtmlPlugin } from 'vite-plugin-html'
|
3
|
3
|
|
4
|
4
|
const GLOB_CONFIG_FILE_NAME = '_app.config.js'
|
5
|
5
|
|
...
|
...
|
@@ -10,34 +10,45 @@ export function configHtmlPlugin(env: ViteEnv, isBuild: boolean): Plugin { |
10
|
10
|
return `${path || '/'}${GLOB_CONFIG_FILE_NAME}?v=${Date.now()}`
|
11
|
11
|
}
|
12
|
12
|
|
13
|
|
- const htmlPlugin = createHtmlPlugin({
|
14
|
|
- minify: isBuild,
|
15
|
|
- inject: {
|
16
|
|
- data: {
|
17
|
|
- title: VITE_GLOB_APP_TITLE,
|
18
|
|
- },
|
19
|
|
- tags: isBuild ? [
|
20
|
|
- {
|
21
|
|
- tag: 'script',
|
22
|
|
- attrs: { src: getAppConfigSrc() }
|
23
|
|
- }
|
24
|
|
- ] : []
|
25
|
|
- }
|
26
|
|
- })
|
|
13
|
+ // const htmlPlugin = createHtmlPlugin({
|
|
14
|
+ // minify: isBuild,
|
|
15
|
+ // inject: {
|
|
16
|
+ // data: {
|
|
17
|
+ // title: VITE_GLOB_APP_TITLE,
|
|
18
|
+ // },
|
|
19
|
+ // tags: isBuild ? [
|
|
20
|
+ // {
|
|
21
|
+ // tag: 'script',
|
|
22
|
+ // attrs: { src: getAppConfigSrc() }
|
|
23
|
+ // }
|
|
24
|
+ // ] : []
|
|
25
|
+ // }
|
|
26
|
+ // })
|
|
27
|
+
|
27
|
28
|
|
28
|
29
|
|
|
30
|
+ const tags:HtmlTagDescriptor[] = [
|
|
31
|
+ {
|
|
32
|
+ tag: 'title',
|
|
33
|
+ children: VITE_GLOB_APP_TITLE
|
|
34
|
+ }
|
|
35
|
+ ]
|
29
|
36
|
|
|
37
|
+ if (isBuild) {
|
|
38
|
+ tags.push(
|
|
39
|
+ {
|
|
40
|
+ tag: 'script',
|
|
41
|
+ attrs: { src: getAppConfigSrc() }
|
|
42
|
+ }
|
|
43
|
+ )
|
|
44
|
+ }
|
30
|
45
|
return {
|
31
|
46
|
name: 'html-plugin',
|
32
|
47
|
transformIndexHtml: (code, ctx) => {
|
|
48
|
+
|
33
|
49
|
return {
|
34
|
50
|
html: code,
|
35
|
|
- tags: isBuild ? [
|
36
|
|
- {
|
37
|
|
- tag: 'script',
|
38
|
|
- attrs: { src: getAppConfigSrc() }
|
39
|
|
- }
|
40
|
|
- ] : []
|
|
51
|
+ tags
|
41
|
52
|
}
|
42
|
53
|
},
|
43
|
54
|
|
...
|
...
|
|