Files
kintone-helper-extenstion/vite.config.js
2025-10-17 14:39:36 +08:00

39 lines
1.2 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { defineConfig } from 'vite';
import webExtension from 'vite-plugin-web-extension';
import { SCRIPT_FILES } from './src/utils/constants.js';
import path from 'path';
const isDev = process.env.NODE_ENV === 'development';
export default defineConfig({
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
},
},
plugins: [
webExtension({
// 这个项目中所有需要注入的脚本都需要在这里指定,因为它们不会自动被插件检测到
// manifest.json 没有指定 content_scripts所有脚本都通过编程注入
additionalInputs: SCRIPT_FILES,
}),
],
build: {
outDir: 'dist', // 输出目录
// Chrome扩展不支持source maps直接禁用以减小包体积
sourcemap: false,
// 开发模式禁用压缩便于调试,生产模式启用压缩优化体积
minify: !isDev,
cssMinify: !isDev,
rollupOptions: !isDev ? undefined : {
output: {
// 开发模式下不压缩文件名,便于调试
chunkFileNames: 'src/[name].js',
entryFileNames: 'src/[name].js',
assetFileNames: 'src/[name].[ext]',
compact: false, // 禁用代码压缩
},
},
},
});