mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-29 02:52: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: '/',
|
||||
assets: ["./src/assets"],
|
||||
assets: ["./src/assets", "./src/stylesheets"],
|
||||
styles: [],
|
||||
outputHashing: process.env['NODE_ENV'] === 'production' ? 'all' : 'none',
|
||||
optimization: process.env['NODE_ENV'] === 'production',
|
||||
|
@ -19,11 +19,18 @@ const persistentCacheStatic = (root: string, options?: serveStatic.ServeStaticOp
|
||||
async function register(app: express.Application) {
|
||||
const srcRoot = path.join(path.dirname(fileURLToPath(import.meta.url)), "..");
|
||||
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`, 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")));
|
||||
} else {
|
||||
app.use(`/${assetPath}/app`, persistentCacheStatic(path.join(srcRoot, "public/app")));
|
||||
|
Loading…
x
Reference in New Issue
Block a user