diff --git a/bin/build.ts b/bin/build.ts index 24fc669..8d3e277 100644 --- a/bin/build.ts +++ b/bin/build.ts @@ -2,8 +2,8 @@ * @Author: zhaojinfeng 121016171@qq.com * @Date: 2023-06-19 10:38:07 * @LastEditors: zhaojinfeng 121016171@qq.com - * @LastEditTime: 2023-06-20 16:41:47 - * @FilePath: \tianheng-design\bin\build.ts + * @LastEditTime: 2023-07-21 04:26:58 + * @FilePath: \vue3\bin\build.ts * @Description: * */ @@ -42,15 +42,25 @@ function buildAComponent(name: string) { }) } +function dirPathToName(dirPath: string) { + let component = '' + + dirPath.split('-').forEach((name) => { + const first = name[0] + component += first.toUpperCase() + name.slice(1) + }) + return component +} + async function renderDTSwithESM(dir: string[]) { - const text = await renderFile(resolve(process.cwd(), './ejs/index.esm.ts.ejs'), { dir }) + const text = await renderFile(resolve(process.cwd(), './ejs/index.esm.ts.ejs'), { dir, dirPathToName }) return Promise.all([ outputFile(resolve(process.cwd(), './es/index.mjs'), text), outputFile(resolve(process.cwd(), './es/index.d.ts'), text), ]) } async function renderDTSwithUMD(dir: string[]) { - const text = await renderFile(resolve(process.cwd(), './ejs/index.umd.ts.ejs'), { dir }) + const text = await renderFile(resolve(process.cwd(), './ejs/index.umd.ts.ejs'), { dir, dirPathToName }) return Promise.all([ outputFile(resolve(process.cwd(), './lib/index.d.ts'), text), ]) diff --git a/ejs/index.esm.ts.ejs b/ejs/index.esm.ts.ejs index 39f13c3..606c371 100644 --- a/ejs/index.esm.ts.ejs +++ b/ejs/index.esm.ts.ejs @@ -1,9 +1,9 @@ -<% dir.forEach(name => { -%> -import <%- name %> from './<%- name %>/index.vue'; +<% dir.forEach(dirPath => { -%> +import <%- dirPathToName(dirPath) %> from './<%- dirPath %>/index.vue'; <% }) -%> export { -<% dir.forEach((name, index) => { -%> - <%- name %><% if (dir.length>index+1) { %>,<% } %> +<% dir.forEach((dirPath, index) => { -%> + <%- dirPathToName(dirPath) %><% if (dir.length>index+1) { %>,<% } %> <% }) -%> } diff --git a/ejs/index.umd.ts.ejs b/ejs/index.umd.ts.ejs index c8b1eea..a4dd4b1 100644 --- a/ejs/index.umd.ts.ejs +++ b/ejs/index.umd.ts.ejs @@ -2,12 +2,12 @@ Object.defineProperty(exports, '__esModule', { value: true }); -<% dir.forEach(name => { -%> -var <%- name %> = require('./<%- name %>/index.js'); +<% dir.forEach(dirPath => { -%> +var <%- dirPathToName(dirPath) %> = require('./<%- dirPath %>/index.js'); <% }) -%> var Components = [ -<% dir.forEach(name => { -%> - <%- name %>, +<% dir.forEach(dirPath => { -%> + <%- dirPathToName(dirPath) %>, <% }) -%> ] diff --git a/packages/upload-single-file/index.vue b/packages/upload-single-file/index.vue index 93c48c8..9be5f57 100644 --- a/packages/upload-single-file/index.vue +++ b/packages/upload-single-file/index.vue @@ -2,14 +2,17 @@ * @Author: zhaojinfeng 121016171@qq.com * @Date: 2023-07-21 00:37:46 * @LastEditors: zhaojinfeng 121016171@qq.com - * @LastEditTime: 2023-07-21 03:31:04 + * @LastEditTime: 2023-07-21 04:02:43 * @FilePath: \vue3\packages\upload-single-file\index.vue * @Description: * -->