valaxy 0.3.3 → 0.3.6
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 +4 -0
- package/dist/chunk-PH3AWAMH.js +83 -0
- package/dist/chunk-QIXBXHEK.js +1 -0
- package/dist/chunk-T3K5KZOK.mjs +1 -0
- package/dist/chunk-VMVPAM4O.mjs +83 -0
- package/dist/{config-408070e9.d.ts → config-97204b79.d.ts} +4 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/node/cli.js +10 -10
- package/dist/node/cli.mjs +10 -10
- package/dist/node/index.d.ts +1 -1
- package/dist/node/index.js +1 -1
- package/dist/node/index.mjs +1 -1
- package/package.json +12 -12
- package/src/client/components/ValaxyToc.vue +50 -4
- package/src/client/pages/index.vue +5 -0
- package/src/node/cli.ts +2 -1
- package/src/node/markdown/check.ts +2 -2
- package/src/node/markdown/index.ts +7 -3
- package/src/node/plugins/extendConfig.ts +0 -8
- package/src/node/plugins/markdown.ts +17 -20
- package/src/node/plugins/preset.ts +7 -14
- package/src/node/plugins/unocss.ts +1 -0
- package/src/node/rss.ts +4 -4
- package/src/node/utils/cli.ts +8 -9
- package/src/node/vite.ts +4 -3
- package/tsup.config.ts +1 -1
- package/dist/chunk-5ERIFSGH.mjs +0 -89
- package/dist/chunk-IJLE4GPY.mjs +0 -1
- package/dist/chunk-M2CMNZU4.js +0 -89
- package/dist/chunk-PFDRHZPF.js +0 -1
package/dist/node/index.d.ts
CHANGED
package/dist/node/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkPH3AWAMHjs = require('../chunk-PH3AWAMH.js');var _chunkQIXBXHEKjs = require('../chunk-QIXBXHEK.js');_chunkQIXBXHEKjs.i.call(void 0, );exports.createServer = _chunkPH3AWAMHjs.g;
|
package/dist/node/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{g as r}from"../chunk-VMVPAM4O.mjs";import{i as o}from"../chunk-T3K5KZOK.mjs";o();export{r as createServer};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "valaxy",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.6",
|
|
4
4
|
"description": "📄 Vite & Vue powered static blog generator.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vite",
|
|
@@ -37,10 +37,11 @@
|
|
|
37
37
|
"critters": "^0.0.16",
|
|
38
38
|
"dayjs": "^1.11.2",
|
|
39
39
|
"escape-html": "^1.0.3",
|
|
40
|
-
"fast-deep-equal": "^3.1.3",
|
|
41
40
|
"feed": "^4.2.2",
|
|
42
41
|
"katex": "^0.15.3",
|
|
42
|
+
"kolorist": "^1.5.1",
|
|
43
43
|
"markdown-it-anchor": "^8.6.4",
|
|
44
|
+
"markdown-it-attrs": "^4.1.4",
|
|
44
45
|
"markdown-it-container": "^3.0.0",
|
|
45
46
|
"markdown-it-emoji": "^2.0.2",
|
|
46
47
|
"markdown-it-link-attributes": "^4.0.0",
|
|
@@ -54,7 +55,7 @@
|
|
|
54
55
|
"sass": "^1.51.0",
|
|
55
56
|
"star-markdown-css": "^0.3.3",
|
|
56
57
|
"unconfig": "^0.3.4",
|
|
57
|
-
"unocss": "^0.33.
|
|
58
|
+
"unocss": "^0.33.4",
|
|
58
59
|
"unplugin-vue-components": "^0.19.5",
|
|
59
60
|
"vite": "^2.9.9",
|
|
60
61
|
"vite-plugin-inspect": "^0.5.0",
|
|
@@ -62,30 +63,29 @@
|
|
|
62
63
|
"vite-plugin-pages": "^0.23.0",
|
|
63
64
|
"vite-plugin-pwa": "^0.12.0",
|
|
64
65
|
"vite-plugin-vue-layouts": "^0.6.0",
|
|
65
|
-
"vite-ssg": "
|
|
66
|
-
"vite-ssg-sitemap": "0.2.
|
|
66
|
+
"vite-ssg": "0.19.2",
|
|
67
|
+
"vite-ssg-sitemap": "0.2.7",
|
|
67
68
|
"vue": "^3.2.33",
|
|
68
|
-
"vue-demi": "^0.12.5",
|
|
69
69
|
"vue-i18n": "^9.1.10",
|
|
70
70
|
"vue-router": "^4.0.15",
|
|
71
|
-
"yargs": "^17.
|
|
71
|
+
"yargs": "^17.5.0"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@types/katex": "^0.14.0",
|
|
75
75
|
"@types/markdown-it-link-attributes": "^3.0.1",
|
|
76
76
|
"@types/nprogress": "^0.2.0",
|
|
77
77
|
"@types/yargs": "^17.0.10",
|
|
78
|
-
"chalk": "4",
|
|
79
|
-
"cross-env": "^7.0.3",
|
|
80
78
|
"debug": "^4.3.4",
|
|
81
79
|
"diacritics": "^1.3.0",
|
|
82
80
|
"https-localhost": "^4.7.1",
|
|
83
|
-
"markdown-it-attrs": "^4.1.4",
|
|
84
81
|
"type-fest": "^2.12.2",
|
|
85
|
-
"vue-tsc": "^0.34.
|
|
82
|
+
"vue-tsc": "^0.34.13"
|
|
83
|
+
},
|
|
84
|
+
"engines": {
|
|
85
|
+
"node": ">=14.0.0"
|
|
86
86
|
},
|
|
87
87
|
"scripts": {
|
|
88
|
-
"build": "tsup --splitting",
|
|
88
|
+
"build": "rimraf dist && tsup --splitting",
|
|
89
89
|
"dev": "tsup --watch --splitting",
|
|
90
90
|
"lint": "eslint \"**/*.{vue,ts,js}\"",
|
|
91
91
|
"preview": "vite preview",
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import {
|
|
2
|
+
import { onMounted, ref, watch } from 'vue'
|
|
3
3
|
import { useI18n } from 'vue-i18n'
|
|
4
4
|
import { useRoute } from 'vue-router'
|
|
5
5
|
|
|
6
|
+
import type { Header } from '../../node/markdown'
|
|
6
7
|
import { useActiveSidebarLinks } from '~/composables'
|
|
7
|
-
|
|
8
|
-
const route = useRoute()
|
|
9
|
-
const headers = computed(() => route.meta.headers)
|
|
8
|
+
import { useConfig } from '~/config'
|
|
10
9
|
|
|
11
10
|
const container = ref()
|
|
12
11
|
const marker = ref()
|
|
@@ -21,6 +20,53 @@ function getStylesByLevel(level: number) {
|
|
|
21
20
|
|
|
22
21
|
const { locale } = useI18n()
|
|
23
22
|
|
|
23
|
+
const config = useConfig()
|
|
24
|
+
|
|
25
|
+
function useHeaders() {
|
|
26
|
+
const headers = ref<Header[]>([])
|
|
27
|
+
const route = useRoute()
|
|
28
|
+
|
|
29
|
+
function generateHeaders() {
|
|
30
|
+
headers.value = []
|
|
31
|
+
|
|
32
|
+
const content = document.querySelector('.markdown-body')
|
|
33
|
+
const levels = config.value.markdownIt.toc!.includeLevel!.map(level => `h${level}`)
|
|
34
|
+
|
|
35
|
+
content?.querySelectorAll(levels as any).forEach((header) => {
|
|
36
|
+
headers.value.push({
|
|
37
|
+
level: header.tagName.toLowerCase().replace('h', ''),
|
|
38
|
+
title: header.textContent.replace('#', ''),
|
|
39
|
+
slug: header.id,
|
|
40
|
+
lang: header.lang || locale.value,
|
|
41
|
+
})
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
watch(() => route.path, () => {
|
|
46
|
+
generateHeaders()
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
onMounted(() => {
|
|
50
|
+
generateHeaders()
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
headers,
|
|
55
|
+
generateHeaders,
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const { headers, generateHeaders } = useHeaders()
|
|
60
|
+
|
|
61
|
+
if (import.meta.hot) {
|
|
62
|
+
import.meta.hot.on('valaxy:md-update', () => {
|
|
63
|
+
setTimeout(() => {
|
|
64
|
+
generateHeaders()
|
|
65
|
+
// 400ms transition
|
|
66
|
+
}, 600)
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
|
|
24
70
|
// todo mobile toc widget
|
|
25
71
|
</script>
|
|
26
72
|
|
package/src/node/cli.ts
CHANGED
|
@@ -8,6 +8,7 @@ import openBrowser from 'open'
|
|
|
8
8
|
|
|
9
9
|
import consola from 'consola'
|
|
10
10
|
|
|
11
|
+
import { yellow } from 'kolorist'
|
|
11
12
|
import { version } from '../../package.json'
|
|
12
13
|
import { resolveOptions } from './options'
|
|
13
14
|
import { bindShortcut, initServer, printInfo } from './utils/cli'
|
|
@@ -142,7 +143,7 @@ cli.command(
|
|
|
142
143
|
}
|
|
143
144
|
|
|
144
145
|
if (ssg) {
|
|
145
|
-
consola.info(
|
|
146
|
+
consola.info(`use ${yellow('vite-ssg')} to do ssg build...`)
|
|
146
147
|
|
|
147
148
|
try {
|
|
148
149
|
await ssgBuild(options, viteConfig)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { cyan, red, yellow } from 'kolorist'
|
|
2
2
|
import consola from 'consola'
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -8,7 +8,7 @@ import consola from 'consola'
|
|
|
8
8
|
export function checkMd(content: string, path: string) {
|
|
9
9
|
if (content.includes('{%') && content.includes('%}')) {
|
|
10
10
|
consola.error(
|
|
11
|
-
`${`${path}\n`} Please ${
|
|
11
|
+
`${`${path}\n`} Please ${red('remove')} ${cyan('{% %}')}, because it conflicts with ${yellow('markdown-it-attrs')}.`,
|
|
12
12
|
)
|
|
13
13
|
}
|
|
14
14
|
}
|
|
@@ -10,7 +10,7 @@ import attrs from 'markdown-it-attrs'
|
|
|
10
10
|
import type { KatexOptions } from 'katex'
|
|
11
11
|
import Katex from './markdown-it/katex'
|
|
12
12
|
import { containerPlugin } from './markdown-it/container'
|
|
13
|
-
import { headingPlugin } from './markdown-it/headings'
|
|
13
|
+
// import { headingPlugin } from './markdown-it/headings'
|
|
14
14
|
import { slugify } from './slugify'
|
|
15
15
|
import { parseHeader } from './markdown-it/parseHeader'
|
|
16
16
|
import { highlight } from './highlight'
|
|
@@ -41,7 +41,10 @@ export interface MarkdownOptions extends MarkdownIt.Options {
|
|
|
41
41
|
permalink?: Anchor.AnchorOptions['permalink']
|
|
42
42
|
}
|
|
43
43
|
// https://github.com/Oktavilla/markdown-it-table-of-contents
|
|
44
|
-
toc?:
|
|
44
|
+
toc?: {
|
|
45
|
+
includeLevel?: number[]
|
|
46
|
+
[key: string]: any
|
|
47
|
+
}
|
|
45
48
|
katex?: KatexOptions
|
|
46
49
|
}
|
|
47
50
|
|
|
@@ -55,7 +58,8 @@ export function setupMarkdownPlugins(md: MarkdownIt, mdOptions: MarkdownOptions
|
|
|
55
58
|
.use(containerPlugin)
|
|
56
59
|
// conflict with {% %}
|
|
57
60
|
.use(attrs)
|
|
58
|
-
|
|
61
|
+
// generate toc in client
|
|
62
|
+
// .use(headingPlugin, mdOptions?.toc?.includeLevel)
|
|
59
63
|
// .use(lineNumberPlugin)
|
|
60
64
|
// https://github.com/arve0/markdown-it-attrs
|
|
61
65
|
// add classes
|
|
@@ -27,15 +27,7 @@ export function createConfigPlugin(options: ResolvedValaxyOptions): Plugin {
|
|
|
27
27
|
entries: [resolve(options.clientRoot, 'main.ts'), options.configFile],
|
|
28
28
|
|
|
29
29
|
include: [
|
|
30
|
-
'vue',
|
|
31
|
-
'vue-router',
|
|
32
|
-
'@vueuse/core',
|
|
33
|
-
'@vueuse/head',
|
|
34
30
|
'dayjs',
|
|
35
|
-
'nprogress',
|
|
36
|
-
],
|
|
37
|
-
exclude: [
|
|
38
|
-
'vue-demi',
|
|
39
31
|
],
|
|
40
32
|
},
|
|
41
33
|
}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import Markdown from 'vite-plugin-md'
|
|
1
|
+
import Markdown, { meta } from 'vite-plugin-md'
|
|
3
2
|
|
|
4
3
|
import type { Plugin } from 'vite'
|
|
5
4
|
import type { ResolvedValaxyOptions } from '../options'
|
|
6
5
|
|
|
7
|
-
import type { MarkdownRenderer } from '../markdown'
|
|
8
6
|
import { setupMarkdownPlugins } from '../markdown'
|
|
9
|
-
import {
|
|
10
|
-
// import { useRoute } from 'vue-router'
|
|
7
|
+
import { checkMd } from '../markdown/check'
|
|
11
8
|
|
|
12
9
|
export type ViteMdOptions = Parameters<typeof Markdown>[0]
|
|
13
10
|
|
|
@@ -16,8 +13,6 @@ export const excerpt_separator = '<!-- more -->'
|
|
|
16
13
|
// https://github.com/antfu/vite-plugin-md
|
|
17
14
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
18
15
|
export function createMarkdownPlugin(options: ResolvedValaxyOptions): Plugin[] {
|
|
19
|
-
let _md: MarkdownRenderer
|
|
20
|
-
|
|
21
16
|
const mdOptions = options.config.markdownIt
|
|
22
17
|
|
|
23
18
|
const defaultOptions: ViteMdOptions = {
|
|
@@ -29,33 +24,35 @@ export function createMarkdownPlugin(options: ResolvedValaxyOptions): Plugin[] {
|
|
|
29
24
|
|
|
30
25
|
excerpt: excerpt_separator,
|
|
31
26
|
|
|
32
|
-
|
|
33
|
-
// avoid conflict with markdown-it-anchor link
|
|
34
|
-
// link(),
|
|
35
|
-
// seems bug, override frontmatter
|
|
36
|
-
// meta(),
|
|
37
|
-
],
|
|
27
|
+
frontmatterPreprocess: meta() as any,
|
|
38
28
|
|
|
39
29
|
markdownItSetup(md) {
|
|
40
30
|
if (mdOptions.config)
|
|
41
31
|
mdOptions.config(md)
|
|
42
32
|
|
|
43
|
-
|
|
33
|
+
setupMarkdownPlugins(md, mdOptions)
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
transforms: {
|
|
37
|
+
before: (code, id) => {
|
|
38
|
+
checkMd(code, id)
|
|
39
|
+
|
|
40
|
+
code.replace('{%', '\{\%')
|
|
41
|
+
code.replace('%}', '\%\}')
|
|
42
|
+
return code
|
|
43
|
+
},
|
|
44
44
|
},
|
|
45
45
|
}
|
|
46
|
+
|
|
46
47
|
return [Markdown(Object.assign(defaultOptions, options.config.markdown)), {
|
|
47
48
|
name: 'valaxy:md',
|
|
48
49
|
handleHotUpdate(ctx) {
|
|
49
50
|
const { file, server } = ctx
|
|
50
51
|
// send headers
|
|
51
|
-
if (file.endsWith('.md')
|
|
52
|
+
if (file.endsWith('.md')) {
|
|
52
53
|
server.ws.send({
|
|
53
54
|
type: 'custom',
|
|
54
|
-
event: 'valaxy:
|
|
55
|
-
data: {
|
|
56
|
-
path: `/${slash(path.relative(`${options.userRoot}/pages`, file))}`,
|
|
57
|
-
pageHeaders: _md.__data.headers,
|
|
58
|
-
},
|
|
55
|
+
event: 'valaxy:md-update',
|
|
59
56
|
})
|
|
60
57
|
}
|
|
61
58
|
},
|
|
@@ -14,10 +14,9 @@ import { VitePWA } from 'vite-plugin-pwa'
|
|
|
14
14
|
import VueI18n from '@intlify/vite-plugin-vue-i18n'
|
|
15
15
|
import Inspect from 'vite-plugin-inspect'
|
|
16
16
|
|
|
17
|
-
import
|
|
17
|
+
import { dim, yellow } from 'kolorist'
|
|
18
18
|
import type { ResolvedValaxyOptions, ValaxyServerOptions } from '../options'
|
|
19
19
|
import { setupMarkdownPlugins } from '../markdown'
|
|
20
|
-
import { checkMd } from '../markdown/check'
|
|
21
20
|
import { createMarkdownPlugin, excerpt_separator } from './markdown'
|
|
22
21
|
import { createUnocssPlugin } from './unocss'
|
|
23
22
|
import { createConfigPlugin } from './extendConfig'
|
|
@@ -40,7 +39,7 @@ export async function ViteValaxyPlugins(
|
|
|
40
39
|
const ValaxyPlugin = createValaxyPlugin(options, serverOptions)
|
|
41
40
|
|
|
42
41
|
const mdIt = new MarkdownIt({ html: true })
|
|
43
|
-
|
|
42
|
+
setupMarkdownPlugins(mdIt, options.config.markdownIt)
|
|
44
43
|
|
|
45
44
|
const roots = [clientRoot, themeRoot, userRoot]
|
|
46
45
|
|
|
@@ -93,7 +92,6 @@ export async function ViteValaxyPlugins(
|
|
|
93
92
|
}),
|
|
94
93
|
|
|
95
94
|
ValaxyPlugin,
|
|
96
|
-
MarkdownPlugin,
|
|
97
95
|
createConfigPlugin(options),
|
|
98
96
|
|
|
99
97
|
ThemePlugin(options.config.themeConfig),
|
|
@@ -110,6 +108,7 @@ export async function ViteValaxyPlugins(
|
|
|
110
108
|
if (!route.meta)
|
|
111
109
|
route.meta = {}
|
|
112
110
|
|
|
111
|
+
// add default layout for home, can be overrode
|
|
113
112
|
if (route.path === '/')
|
|
114
113
|
route.meta.layout = 'home'
|
|
115
114
|
|
|
@@ -120,15 +119,13 @@ export async function ViteValaxyPlugins(
|
|
|
120
119
|
})
|
|
121
120
|
|
|
122
121
|
const md = fs.readFileSync(path, 'utf-8')
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const { data, excerpt, content } = matter(md, { excerpt_separator })
|
|
122
|
+
const { data, excerpt } = matter(md, { excerpt_separator })
|
|
126
123
|
|
|
127
124
|
// warn for post frontmatter
|
|
128
125
|
if (route.path.startsWith('/posts/')) {
|
|
129
126
|
route.meta.layout = 'post'
|
|
130
127
|
if (!data.date)
|
|
131
|
-
consola.warn(`You forgot to write ${
|
|
128
|
+
consola.warn(`You forgot to write ${yellow('date')} for post: ${dim(`${route.component}`)}`)
|
|
132
129
|
}
|
|
133
130
|
|
|
134
131
|
route.meta = Object.assign(route.meta, {
|
|
@@ -136,11 +133,6 @@ export async function ViteValaxyPlugins(
|
|
|
136
133
|
excerpt: excerpt ? mdIt.render(excerpt) : '',
|
|
137
134
|
})
|
|
138
135
|
|
|
139
|
-
// to refactor
|
|
140
|
-
// get active header by runtime query head, not render
|
|
141
|
-
mdIt.render(content)
|
|
142
|
-
route.meta.headers = _md.__data?.headers
|
|
143
|
-
|
|
144
136
|
// set default updated
|
|
145
137
|
if (route.meta.frontmatter.updated)
|
|
146
138
|
route.meta.frontmatter.updated = route.meta.frontmatter.date
|
|
@@ -152,7 +144,6 @@ export async function ViteValaxyPlugins(
|
|
|
152
144
|
return route
|
|
153
145
|
},
|
|
154
146
|
}),
|
|
155
|
-
|
|
156
147
|
// https://github.com/JohnCampionJr/vite-plugin-vue-layouts
|
|
157
148
|
Layouts({
|
|
158
149
|
layoutsDirs: roots.map(root => `${root}/layouts`),
|
|
@@ -180,6 +171,8 @@ export async function ViteValaxyPlugins(
|
|
|
180
171
|
// UnocssPlugin,
|
|
181
172
|
UnocssPlugin,
|
|
182
173
|
|
|
174
|
+
...MarkdownPlugin,
|
|
175
|
+
|
|
183
176
|
// https://github.com/antfu/vite-plugin-pwa
|
|
184
177
|
VitePWA({
|
|
185
178
|
registerType: 'autoUpdate',
|
package/src/node/rss.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { dirname } from 'path'
|
|
2
|
-
import
|
|
2
|
+
import { cyan, dim } from 'kolorist'
|
|
3
3
|
|
|
4
4
|
import fg from 'fast-glob'
|
|
5
5
|
import fs from 'fs-extra'
|
|
@@ -37,7 +37,7 @@ export async function build(options: ResolvedValaxyOptions) {
|
|
|
37
37
|
link: options.config.author.link,
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
consola.info(`RSS Site Url: ${
|
|
40
|
+
consola.info(`RSS Site Url: ${cyan(siteUrl)}`)
|
|
41
41
|
|
|
42
42
|
const ccVersion = (config.license.type === 'zero') ? '1.0' : '4.0'
|
|
43
43
|
const feedOptions: FeedOptions = {
|
|
@@ -64,12 +64,12 @@ export async function build(options: ResolvedValaxyOptions) {
|
|
|
64
64
|
|
|
65
65
|
// not add to posts
|
|
66
66
|
if (!data.date) {
|
|
67
|
-
consola.warn(`Do you forget to write date for ${
|
|
67
|
+
consola.warn(`Do you forget to write date for ${dim(i)}`)
|
|
68
68
|
return false
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
if (data.draft) {
|
|
72
|
-
consola.warn(`Ignore draft post: ${
|
|
72
|
+
consola.warn(`Ignore draft post: ${dim(i)}`)
|
|
73
73
|
return false
|
|
74
74
|
}
|
|
75
75
|
|
package/src/node/utils/cli.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import * as readline from 'readline'
|
|
2
2
|
import path from 'path'
|
|
3
3
|
import os from 'os'
|
|
4
|
-
// import equal from 'fast-deep-equal'
|
|
5
4
|
|
|
6
|
-
import
|
|
5
|
+
import { blue, bold, cyan, dim, gray, green, underline } from 'kolorist'
|
|
7
6
|
import consola from 'consola'
|
|
8
7
|
import type { InlineConfig, ViteDevServer } from 'vite'
|
|
9
8
|
import { createServer } from '../server'
|
|
@@ -15,26 +14,26 @@ let server: ViteDevServer | undefined
|
|
|
15
14
|
|
|
16
15
|
export function printInfo(options: ResolvedValaxyOptions, port?: number, remote?: string | boolean) {
|
|
17
16
|
console.log()
|
|
18
|
-
console.log(` ${
|
|
17
|
+
console.log(` ${bold('🌌 Valaxy')} ${blue(`v${version}`)}`)
|
|
19
18
|
console.log()
|
|
20
|
-
console.log(`${
|
|
21
|
-
console.log(` ${
|
|
19
|
+
console.log(`${dim(' 🪐 theme ')} > ${(options.theme ? green(options.theme) : gray('none'))}`)
|
|
20
|
+
console.log(` ${dim('📁')} ${dim(path.resolve(options.userRoot))}`)
|
|
22
21
|
if (port) {
|
|
23
22
|
console.log()
|
|
24
|
-
console.log(`${
|
|
23
|
+
console.log(`${dim(' Preview ')} > ${cyan(`http://localhost:${bold(port)}/`)}`)
|
|
25
24
|
|
|
26
25
|
if (remote) {
|
|
27
26
|
Object.values(os.networkInterfaces())
|
|
28
27
|
.forEach(v => (v || [])
|
|
29
28
|
.filter(details => details.family === 'IPv4' && !details.address.includes('127.0.0.1'))
|
|
30
29
|
.forEach(({ address }) => {
|
|
31
|
-
console.log(`${
|
|
30
|
+
console.log(`${dim(' Network ')} > ${blue(`http://${address}:${bold(port)}/`)}`)
|
|
32
31
|
}),
|
|
33
32
|
)
|
|
34
33
|
}
|
|
35
34
|
|
|
36
35
|
console.log()
|
|
37
|
-
console.log(`${
|
|
36
|
+
console.log(`${dim(' shortcuts ')} > ${underline('r')}${dim('estart | ')}${underline('o')}${dim('pen | ')}${underline('e')}${dim('dit')}`)
|
|
38
37
|
}
|
|
39
38
|
console.log()
|
|
40
39
|
}
|
|
@@ -56,7 +55,7 @@ export async function initServer(options: ResolvedValaxyOptions, viteConfig: Inl
|
|
|
56
55
|
|
|
57
56
|
if (iconChanged) {
|
|
58
57
|
consola.info('Find new icon, reload server...')
|
|
59
|
-
consola.info(`If you do not want to reload it, write icon name in ${
|
|
58
|
+
consola.info(`If you do not want to reload it, write icon name in ${green('config.unocss.safelist')}.`)
|
|
60
59
|
consola.info('For example: ["i-ri-cloud-line"]')
|
|
61
60
|
console.log()
|
|
62
61
|
reload = true
|
package/src/node/vite.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { join } from 'path'
|
|
2
2
|
import type { InlineConfig } from 'vite'
|
|
3
|
-
import {
|
|
3
|
+
import { splitVendorChunkPlugin } from 'vite'
|
|
4
4
|
import type { ResolvedValaxyOptions, ValaxyServerOptions } from './options'
|
|
5
5
|
|
|
6
6
|
import { ViteValaxyPlugins } from './plugins/preset'
|
|
@@ -29,7 +29,8 @@ export async function createViteConfig(options: ResolvedValaxyOptions, serverOpt
|
|
|
29
29
|
root: options.clientRoot,
|
|
30
30
|
publicDir: join(options.userRoot, 'public'),
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
// https://vitejs.dev/guide/build.html#chunking-strategy
|
|
33
|
+
plugins: [await ViteValaxyPlugins(options, serverOptions, {}), splitVendorChunkPlugin()],
|
|
33
34
|
|
|
34
35
|
server: {
|
|
35
36
|
fs: {
|
|
@@ -37,7 +38,7 @@ export async function createViteConfig(options: ResolvedValaxyOptions, serverOpt
|
|
|
37
38
|
// not need to search workspace root
|
|
38
39
|
options.clientRoot,
|
|
39
40
|
options.themeRoot,
|
|
40
|
-
|
|
41
|
+
options.userRoot,
|
|
41
42
|
],
|
|
42
43
|
},
|
|
43
44
|
},
|
package/tsup.config.ts
CHANGED
|
@@ -3,9 +3,9 @@ import { defineConfig } from 'tsup'
|
|
|
3
3
|
export default defineConfig((options) => {
|
|
4
4
|
return {
|
|
5
5
|
entry: [
|
|
6
|
+
'src/index.ts',
|
|
6
7
|
'src/node/index.ts',
|
|
7
8
|
'src/node/cli.ts',
|
|
8
|
-
'src/index.ts',
|
|
9
9
|
],
|
|
10
10
|
// https://tsup.egoist.sh/#code-splitting
|
|
11
11
|
// Code splitting currently only works with the esm output format, and it's enabled by default. If you want code splitting for cjs output format as well, try using --splitting flag which is an experimental feature to get rid of the limitation in esbuild.
|