super-productivity/packages/plugin-dev/boilerplate-solid-js/vite.config.ts
Johannes Millan d4d81bf511 feat(plugin-api): create foundational plugin API package
- Add @super-productivity/plugin-api package with TypeScript definitions
- Define core plugin interfaces, types, and manifest structure
- Add plugin hooks system for event-driven architecture
- Create plugin API type definitions and constants
- Add documentation and development guidelines
2025-06-27 18:13:19 +02:00

54 lines
1.6 KiB
TypeScript

import { defineConfig } from 'vite';
import solidPlugin from 'vite-plugin-solid';
import { resolve } from 'path';
import fs from 'fs';
import path from 'path';
export default defineConfig({
plugins: [
solidPlugin(),
{
name: 'copy-files',
closeBundle() {
// Copy manifest.json to dist
const manifestSrc = path.resolve(__dirname, 'src/manifest.json');
const manifestDest = path.resolve(__dirname, 'dist/manifest.json');
fs.copyFileSync(manifestSrc, manifestDest);
// Copy icon.svg to dist root
const iconSrc = path.resolve(__dirname, 'src/assets/icon.svg');
const iconDest = path.resolve(__dirname, 'dist/icon.svg');
fs.copyFileSync(iconSrc, iconDest);
// Move index.html from src subdirectory to root
const htmlSrc = path.resolve(__dirname, 'dist/src/index.html');
const htmlDest = path.resolve(__dirname, 'dist/index.html');
if (fs.existsSync(htmlSrc)) {
fs.renameSync(htmlSrc, htmlDest);
// Remove the src directory
fs.rmSync(path.resolve(__dirname, 'dist/src'), {
recursive: true,
force: true,
});
}
},
},
],
build: {
outDir: 'dist',
emptyOutDir: true,
rollupOptions: {
input: {
index: resolve(__dirname, 'src/index.html'),
plugin: resolve(__dirname, 'src/plugin.ts'),
},
output: {
entryFileNames: '[name].js',
chunkFileNames: '[name]-[hash].js',
assetFileNames: '[name].[ext]',
},
},
copyPublicDir: false,
},
publicDir: 'src/assets',
});