question-mark

Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue Description

Is there any suggested setup for production?

In my mind, it would be something like:

app.use(webpackDevMiddleware(compiler, {
    noInfo: true
}));

if (procsss.env.NODE_ENV !== 'production') {
  app.use(webpackHotServerMiddleware(compiler));
} else {
  app.use((req, res) => {
    const stat = require(dist + '/stat.json')
    const server = require(dist + '/server')
    server(stat)(req, res)
  });
}

app.listen(6060, () => {
    console.log('Server started: http://localhost:6060/');
});

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
richardscarrottcommented, Nov 26, 2016

I’ve updated the README with production setup docs – https://github.com/60frames/webpack-hot-server-middleware#production-setup

1reaction
richardscarrottcommented, Oct 5, 2016

@wuct Okay great – I’m not sure what @SpaceK33z would like to rename options.serverSideRender to but I suggested options.exposeStats although that would mean that here, we’d be abusing the fact it happens to also force it to wait for the compiler to stabilise due to an implementation detail.

I also suggested having webpack-dev-middleware simply always wait for the compiler to stabilise but if that isn’t an option then I’d be tempted to suggest creating two options, options.alwaysWaitUntilStable and options.exposeStats so your goNext function would do something like this:

function goNext() {
    if(!options.exposeStats && !options.alwaysWaitUntilStable) return next();
    ready(function() {
        if (options.exposeStats) {
            res.locals.webpackStats = webpackStats;
        }
        next();
    }, req);
}

If that get’s changed in webpack-dev-middleware then I think it’d be a good idea to update the docs here to reflect that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to build a music production setup for under $500
Beginner's Guide: How to build a music production setup for under $500. Get set up to make music at home without breaking the...
Read more >
Production setup requirements - Dynamics 365 - Microsoft Learn
This article provides information about setup requirements before you can work with Production control.
Read more >
Production Setup Jobs, Employment | Indeed.com
24233 Production Setup jobs available on Indeed.com. Apply to Manufacturing Specialist, CNC Machinist, Production Associate and more!
Read more >
Production Setup - Frappe Framework
Production Setup. Bench is the CLI tool to manage deployments for sites based on Frappe Framework. Here are steps to deploy your frappe...
Read more >
Production Run Setup Time Definition & Benchmarks | OpsDog
Production Run Setup Time measures the number of minutes required to setup an operational production run, from the completion of the last unit...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found