| Server IP : 34.87.99.72 / Your IP : 216.73.217.31 Web Server : Apache/2.4.46 (Unix) OpenSSL/1.1.1n System : Linux zlock-bitnami-lamp-prod-v2-vm 4.19.0-16-cloud-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 User : bitnami ( 1000) PHP Version : 7.4.18 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /opt/bitnami/apache/htdocs/app/node_modules/webpack-dev-server/lib/utils/ |
Upload File : |
'use strict';
const { createReadStream } = require('fs');
const { join } = require('path');
const clientBasePath = join(__dirname, '..', '..', 'client');
function routes(server) {
const app = server.app;
const middleware = server.middleware;
app.get('/__webpack_dev_server__/sockjs.bundle.js', (req, res) => {
res.setHeader('Content-Type', 'application/javascript');
createReadStream(
join(clientBasePath, 'modules/sockjs-client/index.js')
).pipe(res);
});
app.get('/webpack-dev-server/invalidate', (_req, res) => {
server.invalidate();
res.end();
});
app.get('/webpack-dev-server', (req, res) => {
middleware.waitUntilValid((stats) => {
res.setHeader('Content-Type', 'text/html');
res.write(
'<!DOCTYPE html><html><head><meta charset="utf-8"/></head><body>'
);
const statsForPrint =
typeof stats.stats !== 'undefined'
? stats.toJson().children
: [stats.toJson()];
res.write(`<h1>Assets Report:</h1>`);
statsForPrint.forEach((item, index) => {
res.write('<div>');
const name =
item.name || (stats.stats ? `unnamed[${index}]` : 'unnamed');
res.write(`<h2>Compilation: ${name}</h2>`);
res.write('<ul>');
const publicPath = item.publicPath === 'auto' ? '' : item.publicPath;
for (const asset of item.assets) {
const assetName = asset.name;
const assetURL = `${publicPath}${assetName}`;
res.write(
`<li>
<strong><a href="${assetURL}" target="_blank">${assetName}</a></strong>
</li>`
);
}
res.write('</ul>');
res.write('</div>');
});
res.end('</body></html>');
});
});
}
module.exports = routes;