-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
83 lines (81 loc) · 2.42 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
import { defineConfig } from 'vite'
import VueDevTools from 'vite-plugin-vue-devtools'
import vue from '@vitejs/plugin-vue'
import path, { join } from 'path'
import { visualizer } from 'rollup-plugin-visualizer'
// Include the rollup-plugin-visualizer if the BUILD_VISUALIZER env var is set to "true"
const buildVisualizerPlugin = process.env.BUILD_VISUALIZER
? visualizer({
filename: path.resolve(__dirname, 'bundle-analyzer/stats-treemap.html'),
template: 'treemap', // sunburst|treemap|network
sourcemap: true,
gzipSize: true,
})
: undefined
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
VueDevTools(),
],
resolve: {
alias: {
// Alias src directory for imports
'@': path.resolve(__dirname, './src/'),
},
},
css: {
devSourcemap: true,
preprocessorOptions: {
scss: {
// Inject the @kong/design-tokens SCSS variables to make them available for all components.
// This is not needed in host applications.
additionalData: '@use "sass:color";@import "@kong/design-tokens/tokens/scss/variables";',
},
},
},
// TODO: If deploying to GitHub pages, enable this line
base: process.env.USE_SANDBOX ? '/markdown/' : '/',
build: {
lib: process.env.USE_SANDBOX
? undefined
: {
entry: path.resolve(__dirname, 'src/index.ts'),
name: 'KongMarkdown',
fileName: (format) => `kong-markdown.${format}.js`,
},
emptyOutDir: true,
minify: true,
sourcemap: true,
rollupOptions: {
external: process.env.USE_SANDBOX ? undefined : ['vue'],
output: process.env.USE_SANDBOX
? undefined
: {
globals: {
vue: 'Vue',
},
exports: 'named',
},
plugins: [
// visualizer must remain last in the list of plugins
buildVisualizerPlugin,
],
},
},
optimizeDeps: {
include: [
'vue',
],
},
server: {
open: !!process.env.USE_SANDBOX,
fs: {
// Allow serving files from one level up from the package root - IMPORTANT - to support the sandbox
allow: [join(__dirname, '..')],
},
},
// Change the root when utilizing the sandbox via USE_SANDBOX=true to use the `/sandbox/*` files
// During the build process, the `/sandbox/*` files are not used and we should default to the package root.
root: process.env.USE_SANDBOX ? './sandbox' : process.cwd(),
})