mirror of
https://github.com/zadam/trilium.git
synced 2025-11-10 07:15:51 +01:00
Merge remote-tracking branch 'origin/develop' into feature/client_typescript_port1
This commit is contained in:
@@ -4,6 +4,8 @@ import { fileURLToPath } from "url";
|
||||
import express from "express";
|
||||
import env from "../services/env.js";
|
||||
import serveStatic from "serve-static";
|
||||
import webpack from "webpack";
|
||||
import webpackMiddleware from "webpack-dev-middleware";
|
||||
|
||||
const persistentCacheStatic = (root: string, options?: serveStatic.ServeStaticOptions<express.Response<any, Record<string, any>>>) => {
|
||||
if (!env.isDev()) {
|
||||
@@ -17,7 +19,22 @@ const persistentCacheStatic = (root: string, options?: serveStatic.ServeStaticOp
|
||||
|
||||
function register(app: express.Application) {
|
||||
const srcRoot = path.join(path.dirname(fileURLToPath(import.meta.url)), '..');
|
||||
app.use(`/${assetPath}/app`, persistentCacheStatic(path.join(srcRoot, 'public/app')));
|
||||
if (env.isDev()) {
|
||||
const frontendCompiler = webpack({
|
||||
mode: "development",
|
||||
entry: {
|
||||
setup: './src/public/app/setup.js',
|
||||
mobile: './src/public/app/mobile.js',
|
||||
desktop: './src/public/app/desktop.js',
|
||||
},
|
||||
devtool: 'source-map',
|
||||
target: 'electron-renderer'
|
||||
});
|
||||
|
||||
app.use(`/${assetPath}/app`, webpackMiddleware(frontendCompiler));
|
||||
} else {
|
||||
app.use(`/${assetPath}/app`, persistentCacheStatic(path.join(srcRoot, 'public/app')));
|
||||
}
|
||||
app.use(`/${assetPath}/app-dist`, persistentCacheStatic(path.join(srcRoot, 'public/app-dist')));
|
||||
app.use(`/${assetPath}/fonts`, persistentCacheStatic(path.join(srcRoot, 'public/fonts')));
|
||||
app.use(`/assets/vX/fonts`, express.static(path.join(srcRoot, 'public/fonts')));
|
||||
|
||||
Reference in New Issue
Block a user