diff --git a/packages/vant-cli/src/commands/build.ts b/packages/vant-cli/src/commands/build.ts index 1660897ad..9ec5b533a 100644 --- a/packages/vant-cli/src/commands/build.ts +++ b/packages/vant-cli/src/commands/build.ts @@ -19,6 +19,7 @@ import { genVeturConfig } from '../compiler/gen-vetur-config'; import { isDir, isSfc, + isAsset, isStyle, isScript, isDemoDir, @@ -41,6 +42,10 @@ async function compileFile(filePath: string) { return compileStyle(filePath); } + if (isAsset(filePath)) { + return Promise.resolve(); + } + return remove(filePath); } diff --git a/packages/vant-cli/src/common/index.ts b/packages/vant-cli/src/common/index.ts index 0feb4efaa..283674fed 100644 --- a/packages/vant-cli/src/common/index.ts +++ b/packages/vant-cli/src/common/index.ts @@ -14,6 +14,7 @@ export const EXT_REGEXP = /\.\w+$/; export const SFC_REGEXP = /\.(vue)$/; export const DEMO_REGEXP = new RegExp('\\' + sep + 'demo$'); export const TEST_REGEXP = new RegExp('\\' + sep + 'test$'); +export const ASSET_REGEXP = /\.(png|jpe?g|gif|webp|ico|jfif|svg|woff2?|ttf)$/i; export const STYLE_REGEXP = /\.(css|less|scss)$/; export const SCRIPT_REGEXP = /\.(js|ts|jsx|tsx)$/; export const ENTRY_EXTS = ['js', 'ts', 'tsx', 'jsx', 'vue']; @@ -60,6 +61,10 @@ export function isTestDir(dir: string) { return TEST_REGEXP.test(dir); } +export function isAsset(path: string) { + return ASSET_REGEXP.test(path); +} + export function isSfc(path: string) { return SFC_REGEXP.test(path); }