-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
vite.build.config.mts
125 lines (121 loc) · 2.69 KB
/
vite.build.config.mts
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import { defineConfig } from 'vite';
import * as path from 'path';
import AutoImport from 'unplugin-auto-import/vite';
import commonjs from '@rollup/plugin-commonjs';
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js';
import dts from 'vite-plugin-dts';
import pkg from './package.json';
import terser from '@rollup/plugin-terser';
import typescript from 'rollup-plugin-typescript2';
import vue from '@vitejs/plugin-vue';
import vuetify, { transformAssetUrls } from 'vite-plugin-vuetify';
import { viteStaticCopy } from 'vite-plugin-static-copy';
const scopedPackageName = pkg.name;
const packageName = scopedPackageName.split('/')[1];
const banner = `/**
* @name ${scopedPackageName}
* @version ${pkg.version}
* @description ${pkg.description}
* @author ${pkg.author}
* @copyright Copyright ${new Date().getFullYear()}, WebDevNerdStuff
* @homepage ${pkg.homepage}
* @repository ${pkg.repository}
* @license ${pkg.license} License
*/
`;
export default defineConfig({
publicDir: false,
build: {
lib: {
entry: './src/plugin/index.ts',
name: packageName,
formats: ['es', 'cjs'],
fileName: format => `${packageName}.${format}.js`,
},
rollupOptions: {
input: {
main: path.resolve(__dirname, './src/plugin/index.ts')
},
external: [
...Object.keys(pkg.dependencies || {}),
/^vuetify($|\/.+)/,
],
output: {
banner,
exports: 'named',
},
},
},
css: {
preprocessorOptions: {
scss: {
api: 'modern-compiler', // or "modern", "legacy"
importers: [],
},
},
},
plugins: [
commonjs(),
AutoImport({
dts: false,
imports: [
'vue',
{
vue: ['CSSProperties'],
}
],
vueTemplate: true,
}),
vue({
script: {
defineModel: true,
},
template: { transformAssetUrls },
}),
dts({
insertTypesEntry: true,
}),
typescript({
check: true,
include: ['./src/plugin/**/*.vue'],
}),
vuetify({
autoImport: true,
styles: 'none',
}),
cssInjectedByJsPlugin({ topExecutionPriority: false }),
viteStaticCopy({
targets: [
{
src: 'src/plugin/styles/*',
dest: 'scss',
},
]
}),
terser({
compress: {
drop_console: ['log'],
},
}),
],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
'@components': path.resolve(__dirname, './src/plugin/components'),
'@composables': path.resolve(__dirname, './src/plugin/composables'),
'@plugin': path.resolve(__dirname, './src/plugin'),
'@root': path.resolve(__dirname, './'),
'@types': path.resolve(__dirname, './src/plugin/types'),
'@utils': path.resolve(__dirname, './src/plugin/utils'),
},
extensions: [
'.js',
'.json',
'.jsx',
'.mjs',
'.ts',
'.tsx',
'.vue',
],
},
});