-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.ssl.config.js
79 lines (73 loc) · 2.1 KB
/
vite.ssl.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
79
import { defineConfig } from "vite";
import { svelte } from "@sveltejs/vite-plugin-svelte";
import autoPreprocess from "svelte-preprocess";
import pkg from "svelte-preprocess";
const { scss } = pkg;
import path from "node:path";
import glob from 'fast-glob';
import basicSsl from '@vitejs/plugin-basic-ssl';
// Find all HTML files and build an object of names and paths to work from
const files = glob.sync(path.resolve(__dirname, 'src') + '/**/*.html').reduce((acc, cur) => {
// we want to keep the path
let name = cur.replace(path.join(__dirname) + '/src/', '').replace('.html', '').replace('/', '-');
// let name = path.basename(cur, '.html');
console.log(name, "->", cur);
acc[name] = cur;
return acc;
}, {});
const scssOptions = {
quietDeps: true,
};
if ( process.env.NODE_ENV == 'development' ) {
scssOptions.additionalData = `$firebird-font-path: "//localhost:5173"; $fa-font-path: "//localhost:5173/fonts";`;
}
console.log(scssOptions);
export default defineConfig({
plugins: [
svelte({
/* plugin options */
preprocess: [scss({})],
}),
{
name: 'configure-response-headers',
configureServer: server => {
server.middlewares.use((_req, res, next) => {
res.setHeader('Access-Control-Request-Private-Network', 'true');
res.setHeader('Access-Control-Allow-Private-Network', 'true');
next();
});
}
},
basicSsl(),
],
root: path.resolve(__dirname, "src"),
build: {
outDir: path.resolve(__dirname, "dist"),
emptyOutDir: true,
rollupOptions: {
input: files
}
},
resolve: {
alias: {
"~bootstrap": path.resolve(__dirname, "node_modules/bootstrap"),
"~open-props": path.resolve(__dirname, "node_modules/open-props"),
},
extensions: [".mjs", ".js", ".ts", ".json", ".svelte", ".scss"],
},
server: {
// port: 8080,
hot: true,
proxy: {
'^/cgi/ping': {
target: 'https://babel.hathitrust.org',
changeOrigin: true
},
},
},
css: {
preprocessorOptions: {
scss: scssOptions,
},
},
});