Skip to content

Commit 4219c24

Browse files
committed
fix: 修复本地启动缺少组件导入的问题
1 parent 54020d3 commit 4219c24

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

packages/devui-vue/devui-cli/commands/create.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ const {
2222
VITEPRESS_SIDEBAR_FILE,
2323
VITEPRESS_SIDEBAR_FILE_NAME,
2424
VITEPRESS_SIDEBAR_FILE_EN,
25-
VITEPRESS_SIDEBAR_FILE_NAME_EN
25+
VITEPRESS_SIDEBAR_FILE_NAME_EN,
26+
isProd
2627
} = require('../shared/constant');
2728
const { isEmpty, kebabCase } = require('lodash');
2829
const inquirer = require('inquirer');
@@ -131,9 +132,9 @@ async function createComponent(params = {}) {
131132
}
132133
}
133134

134-
async function createVueDevui(params, { ignoreParseError }) {
135+
async function createVueDevui(params, { ignoreParseError, env }) {
135136
const fileInfo = resolveDirFilesInfo(DEVUI_DIR, VUE_DEVUI_IGNORE_DIRS)
136-
.filter(({ name }) => parseComponentInfo(kebabCase(name)).status === '100%');
137+
.filter(({ name }) => (env === 'prod' && parseComponentInfo(kebabCase(name)).status === '100%') || !env || env === 'dev');
137138

138139
const exportModules = [];
139140

@@ -176,7 +177,7 @@ async function createVitepressSidebar() {
176177
fileInfo.forEach((f) => {
177178
const info = parseComponentInfo(f.dirname);
178179

179-
if (isEmpty(info) || (process.env.NODE_ENV === 'production'&& info.status !== '100%')) {return;}
180+
if (isEmpty(info) || (isProd && info.status !== '100%')) {return;}
180181

181182
componentsInfo.push(info);
182183
});

packages/devui-vue/devui-cli/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ program
1414
.command('create')
1515
.description('创建一个组件模板或配置文件')
1616
.option('-t --type <type>', `创建类型,可选值:${CREATE_SUPPORT_TYPES.join(', ')}`, validateCreateType)
17+
.option('-e --env <env>', '环境,可选值:dev, prod')
1718
.option('--ignore-parse-error', '忽略解析错误', false)
1819
.option('--cover', '覆盖原文件', false)
1920
.action(create);

packages/devui-vue/devui-cli/shared/constant.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const { resolve } = require('path');
22
const { version } = require('../../package.json');
33

44
exports.VERSION = version;
5+
exports.isProd = process.env.NODE_ENV === 'production';
56
exports.CWD = process.cwd();
67
exports.DEVUI_DIR = resolve(this.CWD, 'devui');
78
exports.DEVUI_NAMESPACE = 'd';

packages/devui-vue/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"scripts": {
2727
"dev": "pnpm generate:theme && vitepress dev docs",
2828
"build": "pnpm generate:theme && node --max-old-space-size=4096 node_modules/vitepress/bin/vitepress.js build docs && cp public/* docs/.vitepress/dist/assets",
29-
"build:lib": "pnpm predev && pnpm build:components && pnpm changelog && pnpm release",
29+
"build:lib": "pnpm predev -- -e prod && pnpm build:components && pnpm changelog && pnpm release",
3030
"test": "jest --config jest.config.js",
3131
"build:components": "node ./devui-cli/index.js build",
3232
"generate:theme": "node ./devui-cli/index.js generate:theme",

0 commit comments

Comments
 (0)