-
Notifications
You must be signed in to change notification settings - Fork 8
/
vite.config.js
78 lines (73 loc) · 1.92 KB
/
vite.config.js
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
/// <reference types="vitest" />
import { configDefaults } from 'vitest/config';
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import license from 'rollup-plugin-license';
const path = require('path');
const minify = process.argv.includes('--minify');
// Change build process based on whether we're building a minified version.
const libConfig = {
minified: {
formats: ['es'],
entry: path.resolve(__dirname, 'src/plugins/imgix-vue/index.ts'),
name: 'imgix-vue',
fileName: () => 'imgix-vue.min.js',
},
default: {
formats: ['es', 'umd'],
entry: path.resolve(__dirname, 'src/plugins/imgix-vue/index.ts'),
name: 'imgix-vue',
fileName: (format) => {
if (format === 'es') {
return `imgix-vue.esm.js`;
}
return `imgix-vue.${format}.js`;
},
},
};
const config = minify ? libConfig.minified : libConfig.default;
export default defineConfig({
test: {
exclude: [...configDefaults.exclude],
include: ['tests/unit/**/*.spec.*'],
globals: true,
environment: 'jsdom',
},
plugins: [vue()],
esbuild: {
legalComments: 'none', // Preserve all legal comments.
banner: '/*! licenses: /vendor.LICENSE.txt */',
},
build: {
// Don't delete the outDir between builds.
// NPM script deletes outDir before building.
emptyOutDir: false,
minify: minify,
target: 'es2018',
lib: {
...config,
},
rollupOptions: {
external: ['vue'],
output: {
// esbuild strips comments, so we need to add a banner to the output in
// order to preserve the licenses.
plugins: [
license({
thirdParty: {
output: path.resolve(__dirname, './dist/vendor.LICENSE.txt'),
},
}),
],
globals: {
vue: 'Vue',
},
},
},
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
});