-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
vite.build.config.mts
100 lines (97 loc) · 2.01 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
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 { 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 || {}),
],
output: {
banner,
exports: 'named',
},
},
},
plugins: [
commonjs(),
AutoImport({
dts: false,
imports: [
'vue',
{
vue: ['CSSProperties']
}
],
vueTemplate: true,
}),
vue({
script: {
defineModel: true,
},
}),
dts({
insertTypesEntry: true,
}),
typescript({
check: true,
include: ['./src/plugin/**/*.vue'],
}),
cssInjectedByJsPlugin({ topExecutionPriority: false }),
viteStaticCopy({
targets: [
{
src: 'src/plugin/styles/*',
dest: 'scss',
},
]
}),
terser(),
],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
'@root': path.resolve(__dirname, './')
},
extensions: [
'.js',
'.json',
'.jsx',
'.mjs',
'.ts',
'.tsx',
'.vue',
],
},
});