3.0.1
Node 10.6.0 / npm 6.4.0 / Windows 10
vue create
and chose my settingsnpm run build
Split CSS from JS, and minify everything.
CSS is still inside JS and not only the JS file app.js
is not being minified, but all eval
s from development are still in there.
I've restarted my computer, deleted node_modules and reinstalled everything. Also I notice the "building for production" text is displayed, so it should be doing the right thing, yet the output app.js
file is 933.61kb in size, and I only have a simple Vue Vuex setup and some CSS, nothing more.
You probably have a default NODE_ENV set in your shell. Delete it, or explicitly set NODE_ENV when running build.
Is it possible to check if there is a "default NODE_ENV" value set anywhere?
@rowild as it turns out, @yyx990803 was right. However, on Windows, I have no idea where that would be set. That said, I added cross-env
and changed my build
script to:
cross-env NODE_ENV=production vue-cli-service build
It solved my problem.
Yes, Chen's tip is totally correct.
I was just wondering, if there is some kind of magic terminal command that spits out, whether I have NODE_ENV defined anywhere globally... :-)
Thank you for your feedback!!!
You can try echo
ing your environment vars directly from the console/terminal/prompt.
This anser and the answer below it covers the main ways of doing that.
For, Windows user, this is what worked for me:
Check NODE_ENV
in the text file:
printenv > env.txt && notepad env.txt
(set NODE_ENV to production
if it is something else)
OR try cross-env
:
npm i -D cross-env
...then in the package.json
cross-env set NODE_ENV=production vue-cli-service build
My 850KB
file sized down to around 82KB
file
Most helpful comment
@rowild as it turns out, @yyx990803 was right. However, on Windows, I have no idea where that would be set. That said, I added
cross-env
and changed mybuild
script to:It solved my problem.