feat(cli): add convention static directory (#8929)

* fix: #8890 sfc compile error

* chore(vant-cli): add convention static directory

* chore(vant-cli): another way to deal with static resources
This commit is contained in:
zoy-l 2021-06-25 17:02:55 +08:00 committed by GitHub
parent 14d0a3136a
commit 384ee56f13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View File

@ -19,6 +19,7 @@ import { genVeturConfig } from '../compiler/gen-vetur-config';
import { import {
isDir, isDir,
isSfc, isSfc,
isAsset,
isStyle, isStyle,
isScript, isScript,
isDemoDir, isDemoDir,
@ -41,6 +42,10 @@ async function compileFile(filePath: string) {
return compileStyle(filePath); return compileStyle(filePath);
} }
if (isAsset(filePath)) {
return Promise.resolve();
}
return remove(filePath); return remove(filePath);
} }

View File

@ -14,6 +14,7 @@ export const EXT_REGEXP = /\.\w+$/;
export const SFC_REGEXP = /\.(vue)$/; export const SFC_REGEXP = /\.(vue)$/;
export const DEMO_REGEXP = new RegExp('\\' + sep + 'demo$'); export const DEMO_REGEXP = new RegExp('\\' + sep + 'demo$');
export const TEST_REGEXP = new RegExp('\\' + sep + 'test$'); 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 STYLE_REGEXP = /\.(css|less|scss)$/;
export const SCRIPT_REGEXP = /\.(js|ts|jsx|tsx)$/; export const SCRIPT_REGEXP = /\.(js|ts|jsx|tsx)$/;
export const ENTRY_EXTS = ['js', 'ts', 'tsx', 'jsx', 'vue']; export const ENTRY_EXTS = ['js', 'ts', 'tsx', 'jsx', 'vue'];
@ -60,6 +61,10 @@ export function isTestDir(dir: string) {
return TEST_REGEXP.test(dir); return TEST_REGEXP.test(dir);
} }
export function isAsset(path: string) {
return ASSET_REGEXP.test(path);
}
export function isSfc(path: string) { export function isSfc(path: string) {
return SFC_REGEXP.test(path); return SFC_REGEXP.test(path);
} }