|
|
@@ -1,8 +1,7 @@
|
|
|
import { defineConfig } from 'vite';
|
|
|
-import dts from 'vite-plugin-dts';
|
|
|
import vue from '@vitejs/plugin-vue';
|
|
|
import path from 'path';
|
|
|
-const fs = require('fs-extra');
|
|
|
+import fs from 'fs-extra';
|
|
|
import config from './package.json';
|
|
|
import configPkg from './src/config.json';
|
|
|
|
|
|
@@ -45,37 +44,6 @@ export default defineConfig({
|
|
|
whitespace: 'preserve'
|
|
|
}
|
|
|
}
|
|
|
- }),
|
|
|
- dts({
|
|
|
- insertTypesEntry: true,
|
|
|
- copyDtsFiles: false,
|
|
|
- cleanVueFileName: false,
|
|
|
- outputDir: path.resolve(__dirname, './dist/types'),
|
|
|
- include: path.resolve(__dirname, './src/packages/__VUE'),
|
|
|
- beforeWriteFile: (filePath: string, content: string) => {
|
|
|
- const fileContent = `import { App, PropType, CSSProperties } from 'vue';
|
|
|
-declare type Install<T> = T & {
|
|
|
- install(app: App): void;
|
|
|
-};
|
|
|
-`;
|
|
|
- const start = 'declare const _sfc_main:';
|
|
|
- const end = ';\nexport default _sfc_main;\n';
|
|
|
- let name = Object.keys(input).find((item: string) => item.toLowerCase() === filePath.split('/').slice(-2)[0]);
|
|
|
- name = name ? name : ' ';
|
|
|
- const remain = `
|
|
|
-declare module 'vue' {
|
|
|
- interface GlobalComponents {
|
|
|
- Nut${name}: typeof _sfc_main;
|
|
|
- }
|
|
|
-}
|
|
|
- `;
|
|
|
- const inputs = content.match(RegExp(`${start}([\\s\\S]*?)${end}`));
|
|
|
- const changeContent = inputs && inputs.length ? `${start} Install<${inputs[1]}>${end}${remain}` : content;
|
|
|
- return {
|
|
|
- filePath,
|
|
|
- content: fileContent + changeContent
|
|
|
- };
|
|
|
- }
|
|
|
})
|
|
|
],
|
|
|
build: {
|