generated from Nodarx/template
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
import { defineConfig } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import path from 'path'
|
|
|
|
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}`)
|
|
}
|
|
}
|
|
},
|
|
},
|
|
],
|
|
resolve: { alias: { '@': path.resolve(__dirname, './src'), '@KTXC': path.resolve(__dirname, '../../core/src') } },
|
|
define: { 'process.env': {}, process: undefined },
|
|
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: info => info.name?.endsWith('.css') ? 'firewall_manager-[hash].css' : '[name]-[hash][extname]' },
|
|
},
|
|
},
|
|
})
|