feat(cli): gen vetur config

This commit is contained in:
陈嘉涵 2019-12-13 09:50:29 +08:00
parent adbaf9b69e
commit 8fc7e6e611
3 changed files with 29 additions and 4 deletions

View File

@ -1,6 +1,8 @@
import { join, relative } from 'path'; import { join, relative } from 'path';
import { clean } from './clean';
import { remove, copy, readdirSync } from 'fs-extra'; import { remove, copy, readdirSync } from 'fs-extra';
import { clean } from './clean';
import { CSS_LANG } from '../common/css';
import { getStepper } from '../common/logger';
import { compileJs } from '../compiler/compile-js'; import { compileJs } from '../compiler/compile-js';
import { compileSfc } from '../compiler/compile-sfc'; import { compileSfc } from '../compiler/compile-sfc';
import { compileStyle } from '../compiler/compile-style'; import { compileStyle } from '../compiler/compile-style';
@ -9,7 +11,8 @@ import { genPackageEntry } from '../compiler/gen-package-entry';
import { genStyleDepsMap } from '../compiler/gen-style-deps-map'; import { genStyleDepsMap } from '../compiler/gen-style-deps-map';
import { genComponentStyle } from '../compiler/gen-component-style'; import { genComponentStyle } from '../compiler/gen-component-style';
import { SRC_DIR, LIB_DIR, ES_DIR } from '../common/constant'; import { SRC_DIR, LIB_DIR, ES_DIR } from '../common/constant';
import { getStepper } from '../common/logger'; import { genPacakgeStyle } from '../compiler/gen-package-style';
import { genVeturConfig } from '../compiler/gen-vetur-config';
import { import {
isDir, isDir,
isSfc, isSfc,
@ -20,8 +23,6 @@ import {
setNodeEnv, setNodeEnv,
setModuleEnv setModuleEnv
} from '../common'; } from '../common';
import { genPacakgeStyle } from '../compiler/gen-package-style';
import { CSS_LANG } from '../common/css';
const stepper = getStepper(10); const stepper = getStepper(10);
@ -102,6 +103,7 @@ async function buildPackedOutputs() {
setModuleEnv('esmodule'); setModuleEnv('esmodule');
await compilePackage(false); await compilePackage(false);
await compilePackage(true); await compilePackage(true);
genVeturConfig();
stepper.success('Build Packed Outputs'); stepper.success('Build Packed Outputs');
} catch (err) { } catch (err) {
stepper.error('Build Packed Outputs', err); stepper.error('Build Packed Outputs', err);

View File

@ -0,0 +1,20 @@
// @ts-ignore
import markdownVetur from '@vant/markdown-vetur';
import { join } from 'path';
import { get } from 'lodash';
import { SRC_DIR, getVantConfig, ROOT } from '../common/constant';
// generate vetur tags & attributes
export function genVeturConfig() {
const vantCongig = getVantConfig();
const options = get(vantCongig, 'build.vetur');
if (options) {
markdownVetur.parseAndWrite({
path: SRC_DIR,
test: /zh-CN\.md/,
outputDir: join(ROOT, 'vetur'),
...options
});
}
}

View File

@ -4,6 +4,9 @@ module.exports = {
skipInstall: ['lazyload'], skipInstall: ['lazyload'],
site: { site: {
publicPath: 'vant/' publicPath: 'vant/'
},
vetur: {
tagPrefix: 'van-'
} }
}, },
site: { site: {