Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(web): default react builds to production when NODE_ENV is not set explicitly #7727

Merged
merged 1 commit into from
Nov 15, 2021

Conversation

ndcunningham
Copy link
Contributor

@ndcunningham ndcunningham commented Nov 12, 2021

Current Behavior

Currently, react builds are not set to default to production (Look at the styles size)

image

Expected Behavior

Running yarn nx run project:build:production will now default NODE_ENV to production

image

Related Issue(s)

Fixes #7410

@vercel
Copy link

vercel bot commented Nov 12, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/nrwl/nx-dev/Bn5pZvecemrW2Eqt7VZoijSVY7nW
✅ Preview: Canceled

@jaysoo jaysoo merged commit 6e801a1 into nrwl:master Nov 15, 2021
@ndcunningham ndcunningham deleted the fix-css-purging-react-builds branch November 15, 2021 20:01
FrozenPandaz pushed a commit that referenced this pull request Nov 15, 2021
@puku0x
Copy link
Contributor

puku0x commented Nov 21, 2021

@ndcunningham @jaysoo It seems process.env.NODE_ENV is conflicted by this PR.

image

@arthurgeek
Copy link

This is still producing big CSS files:

Here's the output of my build run:

$ yarn nx run client:build:production --skip-nx-cache
yarn run v1.22.17
$ /Users/arthurgeek/Development/app/node_modules/.bin/nx run client:build:production --skip-nx-cache

> nx run client:build:production 

warn - Tailwind is not purging unused styles because no template paths have been provided.
warn - If you have manually configured PurgeCSS outside of Tailwind or are deliberately not removing unused styles, set `purge: false` in your Tailwind config file to silence this warning.
warn - https://tailwindcss.com/docs/controlling-file-size/#removing-unused-css
Entrypoint main 136 KiB = runtime.bdc91b7b4b12a0bf.esm.js 1.04 KiB main.e6d8f0ef3ad6652b.css 1.87 KiB main.f95a1cfc8e159d59.esm.js 133 KiB
Entrypoint polyfills 87.3 KiB = runtime.bdc91b7b4b12a0bf.esm.js 1.04 KiB polyfills.7e0034cfe0406d00.esm.js 86.3 KiB
Entrypoint styles [big] 2.77 MiB = runtime.bdc91b7b4b12a0bf.esm.js 1.04 KiB styles.164b3a187a04d07d.css 2.77 MiB
chunk (runtime: runtime) main.e6d8f0ef3ad6652b.css, main.f95a1cfc8e159d59.esm.js (main) 150 KiB (javascript) 2.27 KiB (css/mini-extract) [initial] [rendered]
chunk (runtime: runtime) polyfills.7e0034cfe0406d00.esm.js (polyfills) 276 KiB [initial] [rendered]
chunk (runtime: runtime) styles.164b3a187a04d07d.css (styles) 50 bytes (javascript) 3.47 MiB (css/mini-extract) [initial] [rendered]
chunk (runtime: runtime) runtime.bdc91b7b4b12a0bf.esm.js (runtime) 3.02 KiB [entry] [rendered]
webpack compiled successfully (08148694879505e4)

———————————————————————————————————————————————

>  NX   SUCCESS  Running target "build" succeeded


✨  Done in 14.71s.

And here's my tailwind.config.js file:

const { createGlobPatternsForDependencies } = require('@nrwl/react/tailwind')

module.exports = {
  purge: createGlobPatternsForDependencies(__dirname),
  darkMode: false, // or 'media' or 'class'
  theme: {
    extend: {},
  },
  variants: {
    extend: {},
  },
  plugins: [],
}

@arthurgeek
Copy link

Like mentioned in #7410 the same config works in a Next.js app.

@github-actions
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

React: Tailwind classes are not purged unless explicit NODE_ENV=production setting.
4 participants