59 lines
1.5 KiB
TypeScript
59 lines
1.5 KiB
TypeScript
import { defineConfig } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import path from 'path'
|
|
|
|
// https://vite.dev/config/
|
|
export default defineConfig({
|
|
plugins: [
|
|
vue(),
|
|
{
|
|
name: 'inject-css-filename',
|
|
enforce: 'post',
|
|
generateBundle(_options, bundle) {
|
|
const cssFile = Object.keys(bundle).find(name => name.endsWith('.css'))
|
|
if (!cssFile) return
|
|
|
|
for (const fileName of Object.keys(bundle)) {
|
|
const chunk = bundle[fileName]
|
|
if (chunk.type === 'chunk' && chunk.code.includes('__CSS_FILENAME_PLACEHOLDER__')) {
|
|
chunk.code = chunk.code.replace(/__CSS_FILENAME_PLACEHOLDER__/g, `static/${cssFile}`)
|
|
console.log(`Injected CSS filename "static/${cssFile}" into ${fileName}`)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, './src'),
|
|
'@KTXC': path.resolve(__dirname, '../../core/src'),
|
|
'@KTXM/MailManager': path.resolve(__dirname, '../mail_manager/src'),
|
|
},
|
|
},
|
|
build: {
|
|
outDir: 'static',
|
|
emptyOutDir: true,
|
|
sourcemap: true,
|
|
lib: {
|
|
entry: path.resolve(__dirname, 'src/main.ts'),
|
|
formats: ['es'],
|
|
fileName: () => 'module.mjs',
|
|
},
|
|
rollupOptions: {
|
|
external: [
|
|
'vue',
|
|
'vue-router',
|
|
'pinia',
|
|
],
|
|
output: {
|
|
assetFileNames: (assetInfo) => {
|
|
if (assetInfo.name?.endsWith('.css')) {
|
|
return 'provider_jmapc-[hash].css'
|
|
}
|
|
return '[name]-[hash][extname]'
|
|
}
|
|
}
|
|
},
|
|
},
|
|
})
|