Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(build): run only in dev mode
Elian Doran5ea5bfdb5921
diff --git a/src/routes/assets.ts b/src/routes/assets.tsindex 4af7dae1dc..9c16c91a94 100644--- a/src/routes/assets.ts+++ b/src/routes/assets.ts@@ -7,17 +7,6 @@ import serveStatic from "serve-static";import webpack from "webpack";import webpackMiddleware from "webpack-dev-middleware";-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'-});-const persistentCacheStatic = (root: string, options?: serveStatic.ServeStaticOptions<express.Response<any, Record<string, any>>>) => {if (!env.isDev()) {options = {@@ -30,9 +19,22 @@ const persistentCacheStatic = (root: string, options?: serveStatic.ServeStaticOpfunction register(app: express.Application) {const srcRoot = path.join(path.dirname(fileURLToPath(import.meta.url)), '..');- app.use(`/${assetPath}/app`, webpackMiddleware(frontendCompiler, {-- }));+ 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')));