|
|
@@ -1,5 +1,7 @@
|
|
|
import path from 'path';
|
|
|
|
|
|
+import express from 'express';
|
|
|
+
|
|
|
import { i18n } from '^/config/next-i18next.config';
|
|
|
|
|
|
import loggerFactory from '~/utils/logger';
|
|
|
@@ -27,7 +29,6 @@ class CrowiDev {
|
|
|
this.requireForAutoReloadServer();
|
|
|
|
|
|
this.initPromiseRejectionWarningHandler();
|
|
|
- this.initSwig();
|
|
|
}
|
|
|
|
|
|
initPromiseRejectionWarningHandler() {
|
|
|
@@ -35,10 +36,6 @@ class CrowiDev {
|
|
|
process.on('unhandledRejection', console.dir); // eslint-disable-line no-console
|
|
|
}
|
|
|
|
|
|
- initSwig() {
|
|
|
- swig.setDefaults({ cache: false });
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* require files for node-dev auto reloading
|
|
|
*/
|
|
|
@@ -58,6 +55,8 @@ class CrowiDev {
|
|
|
const port = this.crowi.port;
|
|
|
let server = app;
|
|
|
|
|
|
+ this.setupExpressBeforeListening(app);
|
|
|
+
|
|
|
// for log
|
|
|
let serverUrl = `http://localhost:${port}}`;
|
|
|
|
|
|
@@ -90,12 +89,11 @@ class CrowiDev {
|
|
|
return server;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- *
|
|
|
- * @param {any} app express
|
|
|
- */
|
|
|
+ setupExpressBeforeListening(app) {
|
|
|
+ this.setupNextBundleAnalyzer(app);
|
|
|
+ }
|
|
|
+
|
|
|
setupExpressAfterListening(app) {
|
|
|
- // this.setupHeaderDebugger(app);
|
|
|
// this.setupBrowserSync(app);
|
|
|
this.setupWebpackHmr(app);
|
|
|
this.setupNextjsStackFrame(app);
|
|
|
@@ -128,6 +126,11 @@ class CrowiDev {
|
|
|
// app.use(require('connect-browser-sync')(bs));
|
|
|
// }
|
|
|
|
|
|
+ setupNextBundleAnalyzer(app) {
|
|
|
+ const next = nextFactory(this.crowi);
|
|
|
+ app.use('/analyze', express.static(path.resolve(__dirname, '../../../.next/analyze')));
|
|
|
+ }
|
|
|
+
|
|
|
setupWebpackHmr(app) {
|
|
|
const next = nextFactory(this.crowi);
|
|
|
app.all('/_next/webpack-hmr', next.delegateToNext);
|