forked from onetimesecret/onetimesecret
-
Notifications
You must be signed in to change notification settings - Fork 1
/
vite.config.ts
97 lines (85 loc) · 2.63 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import { defineConfig } from 'vite'
//import { createHtmlPlugin } from 'vite-plugin-html'
import vue from '@vitejs/plugin-vue'
import path from 'path'
// Remember, for security reasons, only variables prefixed with VITE_ are
// available here to prevent accidental exposure of sensitive
// environment variables to the client-side code.
const apiBaseUrl = process.env.VITE_API_BASE_URL || 'https://dev.onetimesecret.com';
export default defineConfig({
root: "./src",
plugins: [
vue({
template: {
compilerOptions: {
}
}
}),
// Uncomment and adjust the createHtmlPlugin configuration as needed
// TODO: Doesn't add the preload <link> to the output index.html
// but it does process the html b/c minify: true works.
// Might be handy for some use cases. Leaving for now.
// Corresponds with the following in the input index.html:
//
// <%~ preloadFonts.map(font => `<link rel="preload" href="${font}" as="font" type="font/woff2">`) %>
//
//createHtmlPlugin({
// minify: false,
// entry: 'main.ts',
// template: 'index.html',
// inject: {
// data: {
// preloadFonts: [
// '/dist/assets/ZillaSlab-Regular.woff2',
// '/dist/assets/ZillaSlab-Regular.woff',
// '/dist/assets/ZillaSlab-Bold.woff2',
// '/dist/assets/ZillaSlab-Bold.woff',
// ]
// }
// }
//})
],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
// Resolves browser console warning:
//
// [Vue warn]: Component provided template option but runtime compilation is
// not supported in this build of Vue. Configure your bundler to alias "vue"
// to "vue/dist/vue.esm-bundler.js".
//
'vue': 'vue/dist/vue.esm-bundler.js'
}
},
assetsInclude: ['**/*.woff', '**/*.woff2'], // Include font files
base: '/dist',
build: {
outDir: '../public/web/dist',
emptyOutDir: true,
manifest: true,
rollupOptions: {
input: {
main: 'src/main.ts', // Explicitly define the entry point here
}
},
// https://guybedford.com/es-module-preloading-integrity
// https://github.com/vitejs/vite/issues/5120#issuecomment-971952210
modulePreload: {
polyfill: true,
},
},
server: {
origin: apiBaseUrl,
},
// Add this section to explicitly include dependencies for pre-bundling
optimizeDeps: {
include: [
// List dependencies that you want to pre-bundle here
// Example: 'vue', 'axios'
//'vue'
]
},
define: {
'process.env.API_BASE_URL': JSON.stringify(apiBaseUrl),
},
})