@bndynet/vue-site 0.1.3 → 0.1.4

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 CHANGED
@@ -50,6 +50,14 @@ npx vue-site build
50
50
  npx vue-site preview
51
51
  ```
52
52
 
53
+ Subpath deploy: pass Vite’s public base on the CLI (overrides `env.vite.base` in `site.config`):
54
+
55
+ ```bash
56
+ npx vue-site build --base=/app/
57
+ # or
58
+ npx vue-site build --base /app/
59
+ ```
60
+
53
61
  Add `"dev": "vue-site dev"` (or `vs dev`) in `package.json` scripts if you like.
54
62
 
55
63
  ## Config reference
package/bin/vue-site.mjs CHANGED
@@ -24,7 +24,45 @@ const cwd = process.cwd()
24
24
  const cwdParent = resolve(cwd, '..')
25
25
  /** Two levels up: monorepos (`apps/docs` importing `../../packages/...`). Omitted when that would be the FS root (too permissive for dev). */
26
26
  const cwdGrandparent = resolve(cwd, '../..')
27
- const command = process.argv[2] || 'dev'
27
+
28
+ /**
29
+ * @param {string[]} argv
30
+ * @returns {{ command: string, cliBase?: string }}
31
+ */
32
+ function parseCliArgv(argv = process.argv) {
33
+ const sub = argv[2]
34
+ const command =
35
+ sub && !sub.startsWith('-')
36
+ ? sub
37
+ : 'dev'
38
+
39
+ let cliBase
40
+ const flagStart = command === sub && sub ? 3 : 2
41
+ for (let i = flagStart; i < argv.length; i++) {
42
+ const a = argv[i]
43
+ if (a === '--base') {
44
+ const v = argv[i + 1]
45
+ if (!v || v.startsWith('-')) {
46
+ console.error(
47
+ '[vue-site] --base requires a value (e.g. --base=/app/ or --base /app/)',
48
+ )
49
+ process.exit(1)
50
+ }
51
+ cliBase = v
52
+ i++
53
+ } else if (a.startsWith('--base=')) {
54
+ const v = a.slice('--base='.length)
55
+ if (!v) {
56
+ console.error(
57
+ '[vue-site] --base= requires a value (e.g. --base=/app/)',
58
+ )
59
+ process.exit(1)
60
+ }
61
+ cliBase = v
62
+ }
63
+ }
64
+ return { command, cliBase }
65
+ }
28
66
 
29
67
  function isLikelyFilesystemRoot(dir) {
30
68
  if (dir === '/' || dir === '//') return true
@@ -215,15 +253,20 @@ function vueSitePlugin() {
215
253
  ]
216
254
  }
217
255
 
218
- async function buildViteConfig() {
256
+ async function buildViteConfig(options = {}) {
257
+ const { cliBase } = options
219
258
  const siteConfig = await loadSiteConfig()
259
+ const env = siteConfig.env || {}
220
260
  const {
221
261
  port,
222
262
  outDir,
223
263
  customElements = [],
224
- watchPackages = [],
225
264
  vite: userVite = {},
226
- } = siteConfig.env || {}
265
+ } = env
266
+ const watchPackages =
267
+ env.watchPackages !== undefined
268
+ ? env.watchPackages
269
+ : siteConfig.watchPackages ?? []
227
270
  const { vue: userVueOpts = {}, plugins: userPlugins, ...userViteRest } =
228
271
  userVite
229
272
 
@@ -335,13 +378,15 @@ async function buildViteConfig() {
335
378
  outDir: resolve(cwd, outDir || `${basename(cwd)}-dist`),
336
379
  emptyOutDir: true,
337
380
  },
381
+ ...(cliBase != null && { base: cliBase }),
338
382
  }
339
383
 
340
384
  return mergeConfig(userViteRest, baseConfig)
341
385
  }
342
386
 
343
387
  async function run() {
344
- const viteConfig = await buildViteConfig()
388
+ const { command, cliBase } = parseCliArgv()
389
+ const viteConfig = await buildViteConfig({ cliBase })
345
390
 
346
391
  if (command === 'dev') {
347
392
  const server = await createServer(viteConfig)
@@ -390,7 +435,10 @@ import { repositoryUrl } from '${VIRTUAL_PACKAGE}'
390
435
  )
391
436
  server.printUrls()
392
437
  } else {
393
- console.log('Usage: vue-site|vs <dev|build|preview>')
438
+ console.log(
439
+ 'Usage: vue-site|vs <dev|build|preview> [--base=<path>]\n' +
440
+ ' --base Public path for assets (overrides env.vite.base); e.g. --base=/app/',
441
+ )
394
442
  process.exit(1)
395
443
  }
396
444
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bndynet/vue-site",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "type": "module",
5
5
  "description": "A configurable Vue 3 site framework with sidebar navigation, markdown rendering, and theme switching.",
6
6
  "repository": {