-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
94 lines (91 loc) · 2.36 KB
/
vite.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import { resolve } from 'path';
import dts from 'vite-plugin-dts';
import sass from 'sass'; // Import Dart Sass
import { visualizer } from 'rollup-plugin-visualizer'; // Import the visualizer plugin
import fs from 'fs-extra';
export default defineConfig(({ mode }) => {
const plugins = [
vue(),
dts({
include: ['src/packagePlugin'],
outputDir: 'dist',
staticImport: true,
skipDiagnostics: false,
rollupTypes: true,
}),
{
name: 'copy-scss',
writeBundle() {
fs.copySync(
resolve(__dirname, 'src/packagePlugin/styles/_gwPopup.scss'),
resolve(__dirname, 'dist/gw-popup.scss'),
);
},
},
// New plugin to copy popupConfig.ts
{
name: 'copy-popup-config',
writeBundle() {
fs.copySync(
resolve(__dirname, 'src/packagePlugin/pinia/PopupConfig.ts'),
resolve(__dirname, 'dist/PopupConfig.ts'),
);
},
},
];
if (process.env.ANALYZE === 'true') {
plugins.push(
visualizer({
filename: 'dist/bundle-analysis.html',
open: true, // Automatically open the report in the browser
gzipSize: true, // Enable gzip size display
}),
);
}
return {
plugins,
build: {
outDir: 'dist',
lib: {
entry: resolve(__dirname, 'src/packagePlugin/index.ts'),
name: 'GWPopup',
fileName: format => `gw-popup.${format}.js`,
},
rollupOptions: {
external: ['vue', '@vueuse/core', 'pinia'],
output: {
exports: 'named',
globals: {
vue: 'Vue',
'@vueuse/core': 'VueUse',
pinia: 'Pinia',
},
assetFileNames: assetInfo => {
if (assetInfo.name === 'style.css') return 'gw-popup.css';
return assetInfo.name;
},
},
},
cssCodeSplit: false,
},
css: {
preprocessorOptions: {
scss: {
silenceDeprecations: ['legacy-js-api'],
implementation: sass, // Explicitly specify Dart Sass
},
},
},
resolve: {
alias: {
'@': resolve(__dirname, 'src'),
'~': resolve(__dirname, 'src/packagePlugin'),
},
},
server: {
port: 3001, // Specify the port you want to use
},
};
});