'use strict'; const { createReadStream } = require('fs'); const { join } = require('path'); const clientBasePath = join(__dirname, '..', '..', 'client'); function routes(app, middleware, options) { app.get('/__webpack_dev_server__/live.bundle.js', (req, res) => { res.setHeader('Content-Type', 'application/javascript'); createReadStream(join(clientBasePath, 'live.bundle.js')).pipe(res); }); app.get('/__webpack_dev_server__/sockjs.bundle.js', (req, res) => { res.setHeader('Content-Type', 'application/javascript'); createReadStream(join(clientBasePath, 'sockjs.bundle.js')).pipe(res); }); app.get('/webpack-dev-server.js', (req, res) => { res.setHeader('Content-Type', 'application/javascript'); createReadStream(join(clientBasePath, 'index.bundle.js')).pipe(res); }); app.get('/webpack-dev-server/*', (req, res) => { res.setHeader('Content-Type', 'text/html'); createReadStream(join(clientBasePath, 'live.html')).pipe(res); }); app.get('/webpack-dev-server', (req, res) => { res.setHeader('Content-Type', 'text/html'); res.write( '
' ); const outputPath = middleware.getFilenameFromUrl(options.publicPath || '/'); const filesystem = middleware.fileSystem; writeDirectory(options.publicPath || '/', outputPath); res.end(''); function writeDirectory(baseUrl, basePath) { const content = filesystem.readdirSync(basePath); res.write('