Netlify returns html for react javascript bundle(blank page)

I’m getting a html doc for my js bundle which results in a blank page. The same build works perfectly fine in my local express server. I have already added the following in netlify.toml,

[[redirects]]
from = “/*”
to = “/index.html”
status = 200

The publish directory is /dist where webpack spits out the html, css and js.

Additional details as follows.

  • we need to know your netlify site name. Example: gifted-antelope-58b104.netlify.app
    https://redv-portfolio.netlify.app/
  • DNS issues? Tell us the custom domain, tell us the error message! We can’t help if we don’t know your domain.
    NA
  • Build problems? Link or paste the FULL build log & build settings screenshot
    js/vendor.bundle.5b53c38178c4374351b9.js returns html instead of js bundle.

Your vendor file is actually being built as js/vendor.bundle.5b53c38178c4374351b9.js.gz

Your webpack config is using:

    new CompressionPlugin({
      filename: '[path].gz',
      algorithm: 'gzip',
      test: /\.(js|jsx|css|html|png|svg|jpg|gif)$/,
      threshold: 10240,
      minRatio: 0.8,
      deleteOriginalAssets: true,
    }),

If you do a build local and serve it up using npx serve dist you should get a better understanding of the issues on your site.

I get a 404 for my gzipped vendor code from npx serve, not sure if it’s cuz of compression but like I said it works fine with my local express static server

Right. What I’m saying is you don’t need to gzip files on Netlify. Netlify does that automatically for those assets. Gzip file serving

2 Likes

Ahh okay I’ve removed the deleteOriginalAssets flag anyway so, original files are served just in case!

1 Like

Sounds like a good way to handle it in the case you decide to host on another server at a later time.

Yep! I’d rather keep my build process platform agnostic. Thanks for the help, the sites up and running now!

1 Like