Skip to content

Commit

Permalink
fix: 发布带上vendors
Browse files Browse the repository at this point in the history
  • Loading branch information
c0dedance committed Nov 1, 2023
1 parent 8a94ac2 commit 4a251ce
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"src/runtime",
"src/theme-default",
"src/shared",
"template.html"
"template.html",
"vendors"
],
"simple-git-hooks": {
"pre-commit": "npx --no -- lint-staged",
Expand Down
4 changes: 1 addition & 3 deletions scripts/prebundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import fs from 'fs-extra'
import { build } from 'esbuild'
import resolve from 'resolve'
import { normalizePath } from 'vite'
import { EXTERNALS } from '../src/node/constant'

const PRE_BUNDLE_DIR = 'vendors'
import { EXTERNALS, PRE_BUNDLE_DIR } from '../src/node/constant'

async function preBundle(deps: string[]) {
const flattenDepMap = {} as Record<string, string>
Expand Down
4 changes: 3 additions & 1 deletion src/node/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import {
CLIENT_OUTPUT,
EXTERNALS,
MASK_SPLITTER,
PRE_BUNDLE_DIR,
PUBLIC_DIR,
ROOT,
SERVER_ENTRY_PATH,
} from './constant'
import { createVitePlugins } from './vitePlugins'
Expand Down Expand Up @@ -212,7 +214,7 @@ export async function bundle(root: string, config: SiteConfig) {
await fs.copy(publicDir, path.join(root, CLIENT_OUTPUT))
}
// 依赖预打包产物复制到 build 目录
const vendorsDir = path.join(process.cwd(), 'vendors')
const vendorsDir = path.join(ROOT, PRE_BUNDLE_DIR)
if (fs.pathExistsSync(vendorsDir)) {
await fs.copy(vendorsDir, path.join(root, CLIENT_OUTPUT))
}
Expand Down
2 changes: 2 additions & 0 deletions src/node/constant/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export const CLIENT_ENTRY_PATH = path.resolve(

export const PUBLIC_DIR = 'public'

export const PRE_BUNDLE_DIR = 'vendors'

export const CLIENT_OUTPUT = 'build' // docs下打包的目录

export const SERVER_ENTRY_PATH = path.resolve(
Expand Down

0 comments on commit 4a251ce

Please sign in to comment.