You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
106 lines
2.7 KiB
JavaScript
106 lines
2.7 KiB
JavaScript
import { defineConfig, splitVendorChunkPlugin } from 'vite';
|
|
import react from '@vitejs/plugin-react';
|
|
import WindiCSS from 'vite-plugin-windicss';
|
|
import { VitePWA } from 'vite-plugin-pwa';
|
|
|
|
const buildDatePlugin = () => {
|
|
return {
|
|
transformIndexHtml(html) {
|
|
const dataString = new Date().toISOString();
|
|
return html.replace(/%BUILD_DATE%/, `${dataString}`);
|
|
},
|
|
};
|
|
};
|
|
// PWA plugin
|
|
const manifestForPlugIn = {
|
|
registerType: 'prompt',
|
|
// includeAssests: ['/src/assets/logo-gh.png'],
|
|
// registerType: 'autoUpdate',
|
|
workbox: {
|
|
globPatterns: ['**/*.{json,js,css,html,ico,png,svg,woff2}'],
|
|
},
|
|
manifest: {
|
|
name: 'Sales CRM',
|
|
short_name: 'Sales CRM',
|
|
description: 'Haina travel global sales CRM system',
|
|
icons: [
|
|
{
|
|
src: '/favicon.ico',
|
|
sizes: '32x32',
|
|
},
|
|
{
|
|
src: '/s-launchericon-192-192.png',
|
|
sizes: '192x192',
|
|
type: 'image/png',
|
|
},
|
|
{
|
|
src: '/s-launchericon-144-144.png',
|
|
sizes: '144x144',
|
|
type: 'image/png',
|
|
},
|
|
{
|
|
src: '/s-launchericon-512-512.png',
|
|
sizes: '512x512',
|
|
type: 'image/png',
|
|
},
|
|
],
|
|
theme_color: '#171717',
|
|
background_color: '#ccd5ae',
|
|
display: 'standalone',
|
|
display_override: ['window-controls-overlay'],
|
|
scope: '/',
|
|
start_url: 'https://sales.mycht.cn/',
|
|
orientation: 'portrait',
|
|
},
|
|
};
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig({
|
|
define: {
|
|
__BUILD_DATE__: JSON.stringify(`${new Date().toISOString()}`),
|
|
},
|
|
plugins: [react(), buildDatePlugin(), WindiCSS(), splitVendorChunkPlugin(), VitePWA(manifestForPlugIn)],
|
|
server: {
|
|
host: '0.0.0.0',
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
'@': '/src',
|
|
},
|
|
},
|
|
build: {
|
|
// outDir: 'distTest',
|
|
emptyOutDir: true,
|
|
sourcemap: true,
|
|
manifest: true,
|
|
chunkSizeWarningLimit: 555,
|
|
rollupOptions: {
|
|
output: {
|
|
manualChunks(id) {
|
|
if (id.includes('react-router-dom') || id.includes('@remix-run') || id.includes('react-router')) {
|
|
return '@react-router';
|
|
}
|
|
if (id.includes('react-chat-elements') || id.includes('emoji-picker-react')) {
|
|
return '@chat';
|
|
}
|
|
},
|
|
},
|
|
},
|
|
// rollupOptions: {
|
|
// output: {
|
|
// manualChunks(id) {
|
|
// if (id.includes('node_modules')) {
|
|
// return id.toString().split('node_modules/')[1].split('/')[0].toString();
|
|
// }
|
|
// },
|
|
// chunkFileNames: (chunkInfo) => {
|
|
// const facadeModuleId = chunkInfo.facadeModuleId ? chunkInfo.facadeModuleId.split('/') : [];
|
|
// return `assets/[name].[hash].js`;
|
|
// }
|
|
// }
|
|
// }
|
|
},
|
|
terserOptions: {
|
|
maxWorkers: 4,
|
|
},
|
|
});
|