server.js 859 B

12345678910111213141516171819202122232425
  1. const webpack = require('webpack');
  2. const middleware = require('webpack-dev-middleware');
  3. const express = require('express');
  4. const path = require('path');
  5. const cors = require('cors');
  6. const webpackConfig = require('./webpack.config.prod');
  7. const compiler = webpack(webpackConfig);
  8. const app = express();
  9. app.use(cors());
  10. app.use(middleware(compiler, { publicPath: '/dist', writeToDisk: true }));
  11. // These headers are required to measure memory within the benchmark code.
  12. // If they are problematic within other contexts they can be removed.
  13. app.use(express.static(path.resolve(__dirname, '..'), {
  14. setHeaders: (res) => {
  15. res.set('Cross-Origin-Opener-Policy', 'same-origin');
  16. res.set('Cross-Origin-Embedder-Policy', 'require-corp');
  17. }
  18. }));
  19. module.exports = app.listen(3000, () => {
  20. console.log('Server is running on the port no. 3000');
  21. });