How to use react-loadable-ssr-addon - 2 common examples

To help you get started, we’ve selected a few react-loadable-ssr-addon examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Sazito / phoenix / server / routes / all.js View on Github external
);

        // get all bundles that are necessary for the current route
        // `stats` is the asset-manifest of application that contains list of all bundles and chunks
        // `modules` is list of current route's modules that detected by react loadable
        const modulesToBeLoaded = [...Array.from(modules)];

        const bundles = getBundles(stats, modulesToBeLoaded);

        const indexFile = path.resolve("./dist/index.html");
        fs.readFile(indexFile, "utf8", (err, indexData) => {
          if (err) {
            console.error("Something went wrong:", err);
            return res.status(500).send("Oops, better luck next time!");
          }

          if (context.status === 404) {
            res.status(404);
          }
          if (context.url) {
            return res.redirect(301, context.url);
          }

          let styles = "";
github themgoncalves / react-loadable-ssr-addon / example / server.js View on Github external
server.get('*', (req, res) => {
  const modules = new Set();
  const html = renderToString(
     modules.add(moduleName)}>
      
    
  );

  const bundles = getBundles(manifest, [...manifest.entrypoints, ...Array.from(modules)]);

  const styles = bundles.css || [];
  const scripts = bundles.js || [];

  res.send(`
    
    
      
        
        
        
        <title>React Loadable SSR Add-on Example</title>
        ${styles.map(style =&gt; {
          return ``;
        }).join('\n')}

react-loadable-ssr-addon

Server Side Render add-on for React Loadable. Load splitted chunks was never that easy.

MIT
Latest version published 3 years ago

Package Health Score

51 / 100
Full package analysis

Popular react-loadable-ssr-addon functions