Fix: webpack optimizations for JS#2235
Conversation
| name: (entrypoint) => `runtime-${entrypoint.name}`, | ||
| }, | ||
| minimizer: [isEnvProduction && new CssMinimizerPlugin()].filter(Boolean), | ||
| minimizer: [new CssMinimizerPlugin(), new TerserPlugin()], |
There was a problem hiding this comment.
Could this lead to a performance impact during development? 🤷♂️
There was a problem hiding this comment.
This is what I thought originally as well (and had the env check)
But looking further into the docs there was this one line in the TerserPlugin docs:
Since version 4 webpack runs optimizations for you depending on the chosen mode, still all optimizations are available for manual configuration and overrides.
And the docs here: https://webpack.js.org/configuration/mode/
But webpack is confusing and maybe I'm wrong 😑.
So what I think happens is in mode dev, minimize gets set to false so these plugins never get run.
Is there a good way to verify this?
There was a problem hiding this comment.
Hmpf, that is super confusing... they're run based on the mode, but they're also configurable manually? I wonder what they mean by that... I think we are configuring them manually here.
I guess you could see if the output bundles are minified in development mode, which would indicate that it's running when it shouldn't be.

There was a problem hiding this comment.
I don't know if source maps are applied to the response 🤷
There was a problem hiding this comment.
Hey @peterp can confirm no minimising on the dev server:

To confirm I've linked the project correctly:
❯ cat node_modules/@redwoodjs/core/config/webpack.common.js | grep minimizer:
minimizer: [new CssMinimizerPlugin(), new TerserPlugin()],
There was a problem hiding this comment.
My understanding of why this works btw:
- When
modeisn't production, webpack automatically sets the flagminimize(not not minimizer) to false - When
optimization.minimizeis false,optimization.minizeris ignored
There was a problem hiding this comment.
Nice, could you leave a comment nearby minimizer so that we don't assume that it's running in dev mode in the future?
b08e8d5 to
7ab07e2
Compare
* Add terser for JS minification * Downgrade terser to 4.x, 5+ not supported on webpack 4 * Add comment about webpack modes
* upgrade Prisma v2.21.0 (#2273) Co-authored-by: Daniel Choudhury <[email protected]> * Fix: webpack optimizations for JS (#2235) * Add terser for JS minification * Downgrade terser to 4.x, 5+ not supported on webpack 4 * Add comment about webpack modes * Adds better messages for rwt link | Watcher does not exist on build failure | Only remove node_modules after a succesful framework build (#2269) * fix(cli): Cli package should depend on api server explicitly (#2251) * upgrade prisma v2.21.2 (#2280) * v0.30.0 Co-authored-by: David Price <[email protected]> Co-authored-by: Daniel Choudhury <[email protected]>
* upgrade Prisma v2.21.0 (#2273) Co-authored-by: Daniel Choudhury <[email protected]> * Fix: webpack optimizations for JS (#2235) * Add terser for JS minification * Downgrade terser to 4.x, 5+ not supported on webpack 4 * Add comment about webpack modes * Adds better messages for rwt link | Watcher does not exist on build failure | Only remove node_modules after a succesful framework build (#2269) * fix(cli): Cli package should depend on api server explicitly (#2251) * upgrade prisma v2.21.2 (#2280) * v0.30.0 * v0.30.1 * Update packages/api/package.json * Update packages/cli/package.json * Update packages/dev-server/package.json * Update packages/create-redwood-app/package.json * Update packages/cli/package.json * Update packages/create-redwood-app/package.json * update crwa/template/yarn.lock to v0.30.1 Co-authored-by: Daniel Choudhury <[email protected]> Co-authored-by: Peter Pistorius <[email protected]>
…erve-web * 'main' of github.com:redwoodjs/redwood: (40 commits) Support generating typescript cells and pages | Autodetect ts project (redwoodjs#2279) create-redwood-app messages: moved app start commands to end (redwoodjs#2278) Add import type to configuration files (redwoodjs#2214) Bump @reach/skip-nav from 0.13.2 to 0.15.0 (redwoodjs#2237) Adding Setup Deploy Render Command (redwoodjs#2099) Disable role linting in Routes (redwoodjs#2318) v0.30.1 (redwoodjs#2322) teardown should attempt to delete dbName table (redwoodjs#2083) Restore @storybook/addon-a11y (redwoodjs#2309) fix(auth): Implement automatic token refresh on supported providers (redwoodjs#2277) fix(cli): move api-server dep from api to cli (redwoodjs#2307) Static typing for cells (redwoodjs#2208) Recommended Babel package upgrades (dependabot) (redwoodjs#2255) v0.30.0 (redwoodjs#2301) upgrade Prisma v2.21.0 (redwoodjs#2273) Further improvements to CONTRIBUTING.md (redwoodjs#2261) Adds better messages for rwt link | Watcher does not exist on build failure | Only remove node_modules after a succesful framework build (redwoodjs#2269) Update named param types in router readme (redwoodjs#2262) Bump core-js from 3.6.5 to 3.10.1 (redwoodjs#2243) Fix: webpack optimizations for JS (redwoodjs#2235) ...
What?
JS wasn't being minified on
yarn rw build web.Adds
TerserPluginto optimizations stage in webpack config to perform minification.Note: I intentionally didn't enabled the
parallel: trueflag, because as noted in their docs on CircleCI for example, it causes issues.