This commit is contained in:
tamaina 2022-04-27 07:11:14 +00:00
parent c32cde5a4a
commit b6109b229d
2 changed files with 16 additions and 3 deletions

View file

@ -4,6 +4,7 @@
import { dirname } from 'node:path'; import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url'; import { fileURLToPath } from 'node:url';
import { PathOrFileDescriptor, readFileSync } from 'node:fs';
import ms from 'ms'; import ms from 'ms';
import Koa from 'koa'; import Koa from 'koa';
import Router from '@koa/router'; import Router from '@koa/router';
@ -74,6 +75,11 @@ app.use(views(_dirname + '/views', {
options: { options: {
version: config.version, version: config.version,
config, config,
...(process.env.NODE_ENV !== 'production' ? {
process,
_dirname,
readFileSync: (path: PathOrFileDescriptor): string => readFileSync(path, 'utf8'),
} : {}),
}, },
})); }));

View file

@ -50,9 +50,16 @@ html
style style
include ../style.css include ../style.css
if process.env.NODE_ENV === 'production'
script. script.
var VERSION = "#{version}"; var VERSION = "#{version}";
var CLIENT_ENTRY = "#{config.clientEntry}"; var CLIENT_ENTRY = "#{config.clientEntry}";
else
-
const clientEntry = JSON.parse(readFileSync(`${_dirname}/../../../../../built/_client_dist_/manifest.json`, 'utf-8'))['src/init.ts'].file.replace(/^_client_dist_\//, '');
script.
var VERSION = "#{version}";
var CLIENT_ENTRY = "#{clientEntry}";
script script
include ../boot.js include ../boot.js