import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import fs from 'fs' import path from 'path' export default defineConfig({ plugins: [ vue(), { name: 'copy-sw-file', writeBundle() { const srcPath = path.resolve(__dirname, 'sw.js') const destPath = path.resolve(__dirname, 'dist', 'sw.js') fs.copyFileSync(srcPath, destPath) console.log('sw.js has been copied to dist folder.') } } ] })