-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathvite.config.js
More file actions
88 lines (85 loc) · 2.25 KB
/
Copy pathvite.config.js
File metadata and controls
88 lines (85 loc) · 2.25 KB
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
import { sveltekit } from '@sveltejs/kit/vite';
import tailwindcss from '@tailwindcss/vite';
import { defineConfig, loadEnv } from 'vite';
// @ts-ignore
export default defineConfig(({ mode }) => {
// Materialize PUBLIC_PRIMARY_COLOR / PUBLIC_SECONDARY_COLOR from .env into
// an in-memory SCSS partial served by a custom Sass importer. `_variables.scss`
// resolves these by doing `@import "env-vars";`. Nothing is written to disk.
const env = loadEnv(mode, process.cwd(), 'PUBLIC_');
const primary = (env.PUBLIC_PRIMARY_COLOR || '').replace(/^"|"$/g, '');
const secondary = (env.PUBLIC_SECONDARY_COLOR || '').replace(/^"|"$/g, '');
const scssEnv =
(primary ? `$env-primary: ${primary};\n` : '') +
(secondary ? `$env-secondary: ${secondary};\n` : '');
return {
// @ts-ignore
plugins: [tailwindcss(), sveltekit(), AutoRefreshHmr()],
ssr: {
noExternal: ['@popperjs/core']
},
optimizeDeps: {
include: [
'svelte',
'@popperjs/core', // Add @popperjs/core to the list of dependencies to include
"overlayscrollbars-svelte",
"svelte-select",
'lodash.get',
'lodash.isequal',
'lodash.clonedeep'
],
exclude: [
"svelte-codemirror-editor",
"codemirror",
"@codemirror/lang-python",
"@codemirror/view",
"@codemirror/state",
"@codemirror/language",
"@codemirror/commands",
"@codemirror/theme-one-dark"
]
},
css: {
preprocessorOptions: {
scss: {
silenceDeprecations: ['import', 'legacy-js-api'],
loadPaths: ['node_modules'],
importers: [
{
/** @param {string} url */
canonicalize(url) {
return url === 'env-vars' ? new URL('sass-virtual:env-vars') : null;
},
/** @param {URL} canonicalUrl */
load(canonicalUrl) {
if (canonicalUrl.protocol === 'sass-virtual:') {
return { contents: scssEnv, syntax: 'scss' };
}
return null;
}
}
]
}
}
},
server: {
port: 5015,
host: "0.0.0.0",
}
};
});
function AutoRefreshHmr() {
return {
name: 'auto-refresh',
enforce: 'post',
// @ts-ignore
handleHotUpdate({ file, server }) {
if (file.endsWith('.svelte') || file.endsWith('.js')) {
server.ws.send({
type: 'full-reload',
path: '*'
});
}
}
};
}