crm/frontend/vite.config.js
jingrow cd44b52409
Some checks failed
Build Container Image / Build (amd64) (push) Has been cancelled
Build Container Image / Build (arm64) (push) Has been cancelled
Generate Semantic Release / Release (push) Has been cancelled
Regenerate POT file (translatable strings) / Regenerate POT file (develop) (push) Has been cancelled
初始提交
2025-10-24 00:34:32 +08:00

124 lines
3.3 KiB
JavaScript

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import path from 'path'
import jingrowui from 'jingrow-ui/vite'
import { VitePWA } from 'vite-plugin-pwa'
// https://vitejs.dev/config/
export default defineConfig(async ({ mode }) => {
const isDev = mode === 'development'
const jingrowui = await importJingrowUIPlugin(isDev)
const config = {
plugins: [
jingrowui({
jingrowProxy: true,
lucideIcons: true,
jinjaBootData: true,
buildConfig: {
indexHtmlPath: '../crm/www/crm.html',
emptyOutDir: true,
sourcemap: true,
},
}),
vue(),
vueJsx(),
VitePWA({
registerType: 'autoUpdate',
devOptions: {
enabled: true,
},
manifest: {
display: 'standalone',
name: 'Jingrow CRM',
short_name: 'Jingrow CRM',
start_url: '/crm',
description:
'Modern & 100% Open-source CRM tool to supercharge your sales operations',
icons: [
{
src: '/assets/crm/manifest/manifest-icon-192.maskable.png',
sizes: '192x192',
type: 'image/png',
purpose: 'any',
},
{
src: '/assets/crm/manifest/manifest-icon-192.maskable.png',
sizes: '192x192',
type: 'image/png',
purpose: 'maskable',
},
{
src: '/assets/crm/manifest/manifest-icon-512.maskable.png',
sizes: '512x512',
type: 'image/png',
purpose: 'any',
},
{
src: '/assets/crm/manifest/manifest-icon-512.maskable.png',
sizes: '512x512',
type: 'image/png',
purpose: 'maskable',
},
],
},
}),
],
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
},
},
optimizeDeps: {
include: [
'feather-icons',
'showdown',
'tailwind.config.js',
'prosemirror-state',
'prosemirror-view',
'lowlight',
'interactjs',
],
},
}
// Add local jingrow-ui alias only in development if the local jingrow-ui exists
if (isDev) {
try {
// Check if the local jingrow-ui directory exists
const fs = await import('node:fs')
const localJingrowUIPath = path.resolve(__dirname, '../jingrow-ui')
if (fs.existsSync(localJingrowUIPath)) {
config.resolve.alias['jingrow-ui'] = localJingrowUIPath
} else {
console.warn('Local jingrow-ui directory not found, using npm package')
}
} catch (error) {
console.warn(
'Error checking for local jingrow-ui, using npm package:',
error.message,
)
}
}
return config
})
async function importJingrowUIPlugin(isDev) {
if (isDev) {
try {
const module = await import('../jingrow-ui/vite')
return module.default
} catch (error) {
console.warn(
'Local jingrow-ui not found, falling back to npm package:',
error.message,
)
}
}
// Fall back to npm package if local import fails
const module = await import('jingrow-ui/vite')
return module.default
}