chore: 添加TypeScript类型定义
This commit is contained in:
@@ -1,13 +1,29 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import { resolve } from 'path';
|
||||
import { readFileSync } from 'fs';
|
||||
import { readFileSync, copyFileSync } from 'fs';
|
||||
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js';
|
||||
|
||||
const pkg = JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf-8'));
|
||||
const banner = `/*! CWDComments widget v${pkg.version} */`;
|
||||
|
||||
function copyDtsPlugin() {
|
||||
return {
|
||||
name: 'copy-dts',
|
||||
closeBundle() {
|
||||
const src = resolve(__dirname, 'src/index.d.ts');
|
||||
const dest = resolve(__dirname, 'dist/index.d.ts');
|
||||
try {
|
||||
copyFileSync(src, dest);
|
||||
console.log(`[copy-dts] Copied ${src} to ${dest}`);
|
||||
} catch (e) {
|
||||
console.error(`[copy-dts] Failed to copy .d.ts file: ${e}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [cssInjectedByJsPlugin()],
|
||||
plugins: [cssInjectedByJsPlugin(), copyDtsPlugin()],
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': resolve(__dirname, 'src'),
|
||||
|
||||
Reference in New Issue
Block a user