mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-10 18:39:22 +08:00
feat(build): run only in dev mode
This commit is contained in:
parent
b3b8ae4a0e
commit
5ea5bfdb59
@ -7,17 +7,6 @@ import serveStatic from "serve-static";
|
|||||||
import webpack from "webpack";
|
import webpack from "webpack";
|
||||||
import webpackMiddleware from "webpack-dev-middleware";
|
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>>>) => {
|
const persistentCacheStatic = (root: string, options?: serveStatic.ServeStaticOptions<express.Response<any, Record<string, any>>>) => {
|
||||||
if (!env.isDev()) {
|
if (!env.isDev()) {
|
||||||
options = {
|
options = {
|
||||||
@ -30,9 +19,22 @@ const persistentCacheStatic = (root: string, options?: serveStatic.ServeStaticOp
|
|||||||
|
|
||||||
function register(app: express.Application) {
|
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)), '..');
|
||||||
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}/app-dist`, persistentCacheStatic(path.join(srcRoot, 'public/app-dist')));
|
||||||
app.use(`/${assetPath}/fonts`, persistentCacheStatic(path.join(srcRoot, 'public/fonts')));
|
app.use(`/${assetPath}/fonts`, persistentCacheStatic(path.join(srcRoot, 'public/fonts')));
|
||||||
app.use(`/assets/vX/fonts`, express.static(path.join(srcRoot, 'public/fonts')));
|
app.use(`/assets/vX/fonts`, express.static(path.join(srcRoot, 'public/fonts')));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user