feat(cli): add css.removeSourceFile config (#10750)
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
import { parse } from 'path';
|
||||
import { readFileSync, writeFileSync } from 'fs';
|
||||
import { replaceExt } from '../common/index.js';
|
||||
import fse from 'fs-extra';
|
||||
import { getVantConfig, replaceExt } from '../common/index.js';
|
||||
import { compileCss } from './compile-css.js';
|
||||
import { compileLess } from './compile-less.js';
|
||||
import { compileSass } from './compile-sass.js';
|
||||
import { consola } from '../common/logger.js';
|
||||
|
||||
const { readFileSync, writeFileSync, removeSync } = fse;
|
||||
|
||||
async function compileFile(filePath: string) {
|
||||
const parsedPath = parse(filePath);
|
||||
|
||||
@@ -30,6 +32,11 @@ async function compileFile(filePath: string) {
|
||||
|
||||
export async function compileStyle(filePath: string) {
|
||||
const css = await compileFile(filePath);
|
||||
const vantConfig = getVantConfig();
|
||||
|
||||
if (vantConfig.build?.css?.removeSourceFile) {
|
||||
removeSync(filePath);
|
||||
}
|
||||
|
||||
writeFileSync(replaceExt(filePath, '.css'), css);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user