mirror of
https://github.com/youzan/vant.git
synced 2025-10-20 02:31:21 +00:00
chore(cli): split compilers
This commit is contained in:
32
packages/vant-cli/src/compiler/gen-package-style.ts
Normal file
32
packages/vant-cli/src/compiler/gen-package-style.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { get } from 'lodash';
|
||||
import { join } from 'path';
|
||||
import { writeFileSync } from 'fs-extra';
|
||||
import { replaceExt } from '../common';
|
||||
import {
|
||||
CONFIG,
|
||||
SRC_DIR,
|
||||
PACKAGE_STYLE_FILE,
|
||||
STYPE_DEPS_JSON_FILE
|
||||
} from '../common/constant';
|
||||
|
||||
// eslint-disable-next-line
|
||||
const styleDepsJson = require(STYPE_DEPS_JSON_FILE);
|
||||
|
||||
function getStyleExt(): string {
|
||||
const preprocessor = get(CONFIG, 'build.css.preprocessor', 'less');
|
||||
|
||||
if (preprocessor === 'sass') {
|
||||
return '.scss';
|
||||
}
|
||||
|
||||
return `.${preprocessor}`;
|
||||
}
|
||||
|
||||
export function genPacakgeStyle() {
|
||||
const ext = getStyleExt();
|
||||
const content = styleDepsJson.sequence
|
||||
.map((name: string) => `@import "${join(SRC_DIR, `${name}/index${ext}`)}";`)
|
||||
.join('\n');
|
||||
|
||||
writeFileSync(replaceExt(PACKAGE_STYLE_FILE, ext), content);
|
||||
}
|
Reference in New Issue
Block a user