Files
website/frontend/vite.config.js
T
2026-05-24 09:30:31 +02:00

65 lines
1.7 KiB
JavaScript

import vituum from "vituum"
import nunjucks from "@vituum/vite-plugin-nunjucks"
import checker from "vite-plugin-checker";
export default {
publicDir: "public",
plugins: [
vituum(),
nunjucks({
root: "./src",
extensions: {
IncludeOnceExtension: includeOnceExtension,
},
}),
checker({
typescript: true,
}),
],
server: {
cors: {
"origin": "*",
"methods": "GET,HEAD,PUT,PATCH,POST,DELETE,OPTIONS",
"preflightContinue": false,
"optionsSuccessStatus": 204
},
proxy: {
'/api': {
target: 'http://localhost:8055',
changeOrigin: false,
rewrite: (path) => path.replace(/^\/api/, ''),
},
}
}
}
function includeOnceExtension() {
this.tagName = "includeOnce";
this.tags = [this.tagName];
this.alreadyIncluded = new Set();
this.parse = function (parser, nodes, _lexer) {
const tag = parser.peekToken();
if (!parser.skipSymbol(this.tagName)) {
parser.fail("parseInclude: expected " + this.tagName);
}
const node = new nodes.Include(tag.lineno, tag.colno);
node.template = parser.parseExpression();
if (parser.skipSymbol("ignore") && parser.skipSymbol("missing")) {
node.ignoreMissing = true;
}
parser.advanceAfterBlockEnd(tag.value);
const includedPath = node.template.value;
if (this.alreadyIncluded.has(includedPath)) {
return new nodes.NodeList(0, 0, []);
}
this.alreadyIncluded.add(includedPath);
return node;
};
}