feat(cli): import base css
This commit is contained in:
@@ -10,6 +10,8 @@ export const CONFIG_FILE = join(CWD, 'vant.config.js');
|
||||
export const PACKAGE_JSON_FILE = join(CWD, 'package.json');
|
||||
export const WEBPACK_CONFIG_FILE = join(CWD, 'webpack.config.js');
|
||||
|
||||
export const STYLE_DIR = join(SRC_DIR, 'style');
|
||||
|
||||
export const DIST_DIR = join(__dirname, '../../dist');
|
||||
export const CONFIG_DIR = join(__dirname, '../config');
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import { get } from 'lodash';
|
||||
import { join, isAbsolute } from 'path';
|
||||
import { CONFIG, STYLE_DIR, SRC_DIR } from './constant';
|
||||
import { existsSync } from 'fs';
|
||||
|
||||
type CSS_LANG = 'css' | 'less' | 'scss';
|
||||
|
||||
function getCssLang(): CSS_LANG {
|
||||
const preprocessor = get(CONFIG, 'build.css.preprocessor', 'less');
|
||||
|
||||
if (preprocessor === 'sass') {
|
||||
return 'scss';
|
||||
}
|
||||
|
||||
return preprocessor;
|
||||
}
|
||||
|
||||
export const CSS_LANG = getCssLang();
|
||||
|
||||
export function getCssBaseFile() {
|
||||
let path = join(STYLE_DIR, `base.${CSS_LANG}`);
|
||||
|
||||
const baseFile = get(CONFIG, 'build.css.base', '');
|
||||
if (baseFile) {
|
||||
path = isAbsolute(baseFile) ? baseFile : join(SRC_DIR, baseFile);
|
||||
}
|
||||
|
||||
if (existsSync(path)) {
|
||||
return path;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
import decamelize from 'decamelize';
|
||||
import { readdirSync, existsSync, lstatSync, readFileSync } from 'fs-extra';
|
||||
import { join } from 'path';
|
||||
import { SRC_DIR, WEBPACK_CONFIG_FILE } from './constant';
|
||||
import { get } from 'lodash';
|
||||
import { readdirSync, existsSync, lstatSync, readFileSync } from 'fs-extra';
|
||||
import { CONFIG, SRC_DIR, WEBPACK_CONFIG_FILE } from './constant';
|
||||
|
||||
export const EXT_REGEXP = /\.\w+$/;
|
||||
export const SFC_REGEXP = /\.(vue)$/;
|
||||
@@ -103,4 +104,14 @@ export function isDev() {
|
||||
return process.env.NODE_ENV === 'development';
|
||||
}
|
||||
|
||||
export function getCssLang(): string {
|
||||
const preprocessor = get(CONFIG, 'build.css.preprocessor', 'less');
|
||||
|
||||
if (preprocessor === 'sass') {
|
||||
return 'scss';
|
||||
}
|
||||
|
||||
return preprocessor;
|
||||
}
|
||||
|
||||
export { decamelize };
|
||||
|
||||
Reference in New Issue
Block a user