Repository navigation
Expand file tree
/
Copy pathvite.config.js
More file actions
54 lines (51 loc) · 1.48 KB
/
Copy pathvite.config.js
File metadata and controls
54 lines (51 loc) · 1.48 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
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
// Applied to the packaged renderer only. The dev server injects inline scripts
// for HMR and React refresh, which this policy would block.
// Styles stay inline-capable because React, Mantine and BlockNote set style
// attributes and inject <style> tags. Note media can be pasted from the web, so
// images and media also allow http(s). The renderer fetches data: URLs to turn
// them into asset files.
const CONTENT_SECURITY_POLICY = [
"default-src 'self'",
"script-src 'self'",
"style-src 'self' 'unsafe-inline'",
"img-src 'self' data: blob: notepane-asset: https: http:",
"media-src 'self' data: blob: notepane-asset: https: http:",
"font-src 'self' data:",
"connect-src 'self' data: blob: notepane-asset:",
"object-src 'none'",
"frame-src 'none'",
"worker-src 'none'",
"base-uri 'none'",
"form-action 'none'",
].join("; ");
function contentSecurityPolicy() {
return {
name: "notepane-content-security-policy",
apply: "build",
transformIndexHtml() {
return [
{
tag: "meta",
attrs: {
"http-equiv": "Content-Security-Policy",
content: CONTENT_SECURITY_POLICY,
},
injectTo: "head-prepend",
},
];
},
};
}
export default defineConfig({
plugins: [react(), contentSecurityPolicy()],
base: "./",
build: {
outDir: "dist",
emptyOutDir: true,
},
server: {
host: "127.0.0.1",
},
});