@bndynet/vue-site 1.2.0 → 1.2.1

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/bin/vue-site.mjs CHANGED
@@ -12,6 +12,9 @@ const __filename = fileURLToPath(import.meta.url)
12
12
  const __dirname = dirname(__filename)
13
13
  const pkgDir = resolve(__dirname, '..')
14
14
  const require = createRequire(import.meta.url)
15
+ const FRAMEWORK_PACKAGE = '@bndynet/vue-site'
16
+ const frameworkEntry = resolve(pkgDir, 'dist/index.es.js')
17
+ const frameworkStyle = resolve(pkgDir, 'dist/style.css')
15
18
 
16
19
  function resolvePkgDir(pkg) {
17
20
  return dirname(require.resolve(`${pkg}/package.json`))
@@ -208,13 +211,12 @@ function buildBootstrapScript({ siteConfig, siteConfigSpecifier }) {
208
211
  bs != null && String(bs).trim() !== ''
209
212
  ? `import '${resolveBootstrapUrl(bs)}'\n`
210
213
  : ''
211
- const pkgDirUrl = pkgDir.replace(/\\/g, '/')
212
214
  return [
213
215
  bootstrapImport,
214
216
  `import 'element-plus/dist/index.css'`,
215
217
  `import 'element-plus/theme-chalk/dark/css-vars.css'`,
216
- `import { createSiteApp } from '${pkgDirUrl}/dist/index.es.js'`,
217
- `import '${pkgDirUrl}/dist/style.css'`,
218
+ `import { createSiteApp } from '${FRAMEWORK_PACKAGE}'`,
219
+ `import '${FRAMEWORK_PACKAGE}/style.css'`,
218
220
  `import siteConfig from '${siteConfigSpecifier}'`,
219
221
  `import { repositoryUrl } from '${VIRTUAL_PACKAGE}'`,
220
222
  ``,
@@ -654,10 +656,21 @@ async function buildViteConfig(options = {}) {
654
656
  root: cwd,
655
657
  plugins: [localizedPageSugarPlugin(), vue(vueOpts), ...watchedScssPlugin, ...vueSitePlugin(entryCode), ...(userPlugins || [])],
656
658
  resolve: {
657
- alias: {
658
- vue: resolve(vuePath, 'dist/vue.runtime.esm-bundler.js'),
659
- 'vue-router': resolve(vueRouterPath, 'dist/vue-router.mjs'),
660
- },
659
+ alias: [
660
+ { find: /^@bndynet\/vue-site$/, replacement: frameworkEntry },
661
+ {
662
+ find: /^@bndynet\/vue-site\/style\.css$/,
663
+ replacement: frameworkStyle,
664
+ },
665
+ {
666
+ find: 'vue',
667
+ replacement: resolve(vuePath, 'dist/vue.runtime.esm-bundler.js'),
668
+ },
669
+ {
670
+ find: 'vue-router',
671
+ replacement: resolve(vueRouterPath, 'dist/vue-router.mjs'),
672
+ },
673
+ ],
661
674
  },
662
675
  optimizeDeps: {
663
676
  // Pre-bundle element-plus so Vite crawls its dependency graph and
@@ -667,6 +680,10 @@ async function buildViteConfig(options = {}) {
667
680
  // The virtual entry only imports element-plus CSS, so Vite's static
668
681
  // analysis never sees the JS side — this include bridges that gap.
669
682
  include: ['element-plus'],
683
+ // The virtual entry and user-authored pages both import the framework.
684
+ // Keep it out of dependency pre-bundling so Vite does not instantiate
685
+ // `dist/index.es.js` once via /@fs and again via node_modules/.vite.
686
+ exclude: [FRAMEWORK_PACKAGE],
670
687
  },
671
688
  server: {
672
689
  open: true,
@@ -4,6 +4,7 @@ export interface SiteContext {
4
4
  config: SiteConfig;
5
5
  resolvedNav: ResolvedNavItem[];
6
6
  }
7
+ /** Use `Symbol.for` so pages still inject context if Vite resolves the package twice. */
7
8
  export declare const siteContextKey: InjectionKey<SiteContext>;
8
9
  export declare function provideSiteConfig(context: SiteContext): void;
9
10
  export declare function useSiteConfig(): SiteContext;