next.js icon indicating copy to clipboard operation
next.js copied to clipboard

Production build is not minified

Open omar-bz opened this issue 8 years ago • 10 comments

In #3632 I was told that next js minify every thing, but this is not the case for me, next js don't minify files, i created a repo (https://github.com/bouzoumita/minify-next-js) contain a project with a large file about 300kb filled with comments, when building it, next does not erase those comment and the size of the output still enormous ~800kb due to comments(without comment it is about ~300kb). Can someone please help me with this code and tell me how to make it shrink.

Thanks.

omar-bz avatar Jan 30 '18 19:01 omar-bz

I’ve been having similar troubles, and our bundle size has ballooned about 20% when upgrading to 5.0.0. Tree shaking (#2999) doesn’t seem to be occurring for us.

ticky avatar Feb 10 '18 01:02 ticky

We did some optimizations for uglifyjs focused on the build speed. (We simply do white space removing). We may need to change some of those settings.

arunoda avatar Feb 10 '18 03:02 arunoda

I'm not even seeing white space removal right now. From looking at the bundle, it looks like Webpack is being run in dev mode.

Do we have the ability to turn some of those optimizations back on? Our gzipped bundle ballooned 67%.

sfrieson-tm avatar Feb 22 '18 17:02 sfrieson-tm

@arunoda @timneutkens is there any update on this? I’m holding off on deploying 5.0 as this is a big jump

ticky avatar Mar 14 '18 18:03 ticky

Try next@canary.

timneutkens avatar Mar 14 '18 18:03 timneutkens

Ok, tested with canary: next 4.2.3: 589.16 KB next 5.0.1-canary.15: 695.54 KB (18% increase)

ticky avatar Mar 16 '18 23:03 ticky

any progress??

ufhy avatar May 12 '18 16:05 ufhy

Fixed in #4536

timneutkens avatar Jun 05 '18 16:06 timneutkens

I'm using latest canary version (6.1.1-canary.0) but build is not minified (js & css). Do I have to add sth to one of the configs?

next.config:

const withTypescript = require('@zeit/next-typescript');
const withOptimizedImages = require('next-optimized-images');
const withCss = require('@zeit/next-css');
module.exports = withTypescript(withOptimizedImages(withCss()));

.babelrc:

{
  "presets": [
    "next/babel",
    "@zeit/next-typescript/babel"
  ],
  "plugins": [
    [
      "styled-components",
      {
        "ssr": true,
        "displayName": true
      }
    ]
  ]
}

Thanks!

r0b- avatar Jul 07 '18 09:07 r0b-

Using cssnano fixed this. Here I am using TailwindCSS.

module.exports = {
    plugins: [
        tailwind("./tailwind.config.js"), 
        autoprefixer, 
        nano
    ]
};

euchicosousa avatar Dec 16 '18 02:12 euchicosousa