mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-29 19:12:27 +08:00
refactor(nx/server): fix proxying of stylesheets
This commit is contained in:
parent
0d4de2a7dd
commit
b2d051edee
@ -42,7 +42,7 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
baseHref: '/',
|
baseHref: '/',
|
||||||
assets: ["./src/assets"],
|
assets: ["./src/assets", "./src/stylesheets"],
|
||||||
styles: [],
|
styles: [],
|
||||||
outputHashing: process.env['NODE_ENV'] === 'production' ? 'all' : 'none',
|
outputHashing: process.env['NODE_ENV'] === 'production' ? 'all' : 'none',
|
||||||
optimization: process.env['NODE_ENV'] === 'production',
|
optimization: process.env['NODE_ENV'] === 'production',
|
||||||
|
@ -19,11 +19,18 @@ const persistentCacheStatic = (root: string, options?: serveStatic.ServeStaticOp
|
|||||||
async function register(app: express.Application) {
|
async function register(app: express.Application) {
|
||||||
const srcRoot = path.join(path.dirname(fileURLToPath(import.meta.url)), "..");
|
const srcRoot = path.join(path.dirname(fileURLToPath(import.meta.url)), "..");
|
||||||
if (isDev) {
|
if (isDev) {
|
||||||
const clientProxy = proxy(process.env.TRILIUM_PUBLIC_SERVER);
|
const publicUrl = process.env.TRILIUM_PUBLIC_SERVER;
|
||||||
|
if (!publicUrl) {
|
||||||
|
throw new Error("Missing TRILIUM_PUBLIC_SERVER");
|
||||||
|
}
|
||||||
|
|
||||||
|
const clientProxy = proxy(publicUrl);
|
||||||
app.use(`/${assetPath}/app/doc_notes`, persistentCacheStatic(path.join(srcRoot, "public/app/doc_notes")));
|
app.use(`/${assetPath}/app/doc_notes`, persistentCacheStatic(path.join(srcRoot, "public/app/doc_notes")));
|
||||||
app.use(`/${assetPath}/app`, clientProxy);
|
app.use(`/${assetPath}/app`, clientProxy);
|
||||||
app.use(`/${assetPath}/app-dist`, clientProxy);
|
app.use(`/${assetPath}/app-dist`, clientProxy);
|
||||||
app.use(`/${assetPath}/stylesheets`, persistentCacheStatic(path.join(srcRoot, "../../client/stylesheets")));
|
app.use(`/${assetPath}/stylesheets`, proxy(publicUrl, {
|
||||||
|
proxyReqPathResolver: (req) => "/stylesheets" + req.url
|
||||||
|
}));
|
||||||
app.use(`/${assetPath}/libraries`, persistentCacheStatic(path.join(srcRoot, "../../client/libraries")));
|
app.use(`/${assetPath}/libraries`, persistentCacheStatic(path.join(srcRoot, "../../client/libraries")));
|
||||||
} else {
|
} else {
|
||||||
app.use(`/${assetPath}/app`, persistentCacheStatic(path.join(srcRoot, "public/app")));
|
app.use(`/${assetPath}/app`, persistentCacheStatic(path.join(srcRoot, "public/app")));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user