`NODE_ENV` equals `development` in PostCSS during `vite build`
See original GitHub issueDescribe the bug
I’m trying to use purge css plugin with PostCSS, but I’ve noticed that it doesn’t work automatically because the NODE_ENV
is set to development
instead of production
during vite build
.
Reproduction
https://github.com/KubaJastrz/vite-postcss-node-env-repro
- clone the repo
- install deps -
yarn
- build production bundle -
yarn build
- observe
"development"
being logged (coming from tailwind.config.js) - generated css file is over 1MB, while it should be much smaller after purging unused classes
System Info
- required
vite
version: 1.0.0-rc.4 - required Operating System: windows 10
- required Node version: 12.11.0
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Configuring Vite
Base public path when served in development or production. ... Entries will be defined as globals during dev and statically replaced during build....
Read more >Output - webpack
The top-level output key contains a set of options instructing webpack on how and where it should output your bundles, assets, and anything...
Read more >Vite - Next generation web build tools - YouTube
Vite.js, a JavaScript development server that significantly improves the frontend ... Most notably, Vite serves your source files over na...
Read more >How to solve my problem? (npm run build) - Laracasts
npm run build > build > vite build vite v3.1.0 building for production. ... during build: TypeError: [postcss] Cannot read properties of undefined...
Read more >nodeenv · PyPI
js virtual environment) is a tool to create isolated node.js environments. It creates an environment that has its own installation directories, that doesn't ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Or, you can use the
.env
file in a specificmode
to specify the value ofNODE_ENV
.In
package.json
you can just make it like the code below:In
.env.development
In
.env.production
Related source code
Thanks @mitchbne. That’s exactly what I did in my project for the time being.