-
Notifications
You must be signed in to change notification settings - Fork 2
/
vite.config.ts
73 lines (63 loc) · 1.7 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
import path from 'path';
import dts from 'vite-plugin-dts'
import { defineConfig } from 'vite';
import license from 'rollup-plugin-license';
import * as pkg from './package.json';
const NODE_ENV = process.argv.mode || 'development';
const VERSION = pkg.version;
/**
* Trick to use Vite server.open option on macOS
* @see https://github.com/facebook/create-react-app/pull/1690#issuecomment-283518768
*/
process.env.BROWSER = 'open';
export default defineConfig(() => {
return {
build: {
copyPublicDir: false,
lib: {
entry: path.resolve(__dirname, 'src', 'index.ts'),
name: 'HawkCatcher',
fileName: 'hawk',
},
rollupOptions: {
plugins: [
license({
thirdParty: {
allow: {
test: (dependency) => {
// Return false for unlicensed dependencies.
if (!dependency.license) {
return false;
}
// Allow MIT and Apache-2.0 licenses.
return ['MIT', 'Apache-2.0'].includes(dependency.license);
},
failOnUnlicensed: true,
failOnViolation: true,
},
output: path.resolve(__dirname, 'dist', 'vendor.LICENSE.txt'),
},
}),
],
},
},
define: {
'NODE_ENV': JSON.stringify(NODE_ENV),
'VERSION': JSON.stringify(VERSION),
},
resolve: {
alias: {
'@/types': path.resolve(__dirname, './types'),
},
},
server: {
port: 3303,
open: './example/index.html',
},
plugins: [
dts({
tsconfigPath: './tsconfig.json',
}),
],
}
});