-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Test and dev builds omit css and image files #2625
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
Comments
I think this comes down to the problem of your documentation not explaining the different implacts of So I'll try and explain what we want to get across, and maybe you can give feedback how we can word or strcuture this part of the documentation. Have you read the documentation about environment variables and modes? this one: https://cli.vuejs.org/guide/mode-and-env.html#environment-variables-and-modes It has an explicit note about NODE_ENV:
So the immediate solution to your problem is to call your build process with an explicitly set In the next section about modes it explains in the first paragraph, that In other words: Similarly, When you are running Does that make it clearer? And if it does, what would you like to read about this in the docs, and where would you expect to find it? We don't always find it easy to get docs for things like this right the first time, as it's hard for someone intimately familiar with a tool to think about things from a new user's perspective on it. |
@LinusBorg The solution you provide for the build works fine, thanks. I'm using a pipeline to push to the different environments, and I remember I had thought of that solution reading the yellow note on NODE_ENV in the docs, but wasn't happy with it because it doesn't work on Windows and Linux alike. Anyway, it's good enough for now. What I'm generally wondering is why does NODE_ENV have to match the webpack production mode? The env var will set different URLs or texts or whatever for different environments, whereas the webpack production mode affects the build itself, like which files to include, source maps, pruning and the whole lot. This seems to be not necessarily related to me. Like in my case, I could want to deploy an app to a dev system or a test system, where the env vars are set accordingly, but the build should be a production build. Would it be awkward to keep NODE_ENV and webpack mode independent? [edit] And I don't know if that ties in with that, but if my NODE_ENV is set to "test" and I call |
I think this is another misunderstanding. vue-cli's Webpack's Our
So the point is:
That's because we never overwrite any environment variable that was being passed in from the system running vue-cli-service. So I'm aware that this is maybe not the most straightforward way to handle this, but it's the best way we found so far that allows for the flexibility we need to support various ways to define env vars and different modes. |
Great explanation again, thanks for that. Now I have it, I believe, and enough material to improve the docs :-) Two more related questions:
That makes sense, but the resulting build should be a production build, no?! If NODE_ENV is "test" and I run And secondly, when I have an actual production build with all assets included, there's nevertheless an output saying "Images and other types of assets omitted.". Why is that? |
No. As I explained, the NODE_ENV value is what actually determines the kind of webpack config you get. And since we do not overwrite environment variables from the system, you run a build with a test config if your system has defined As to the second question, I believe that's simply referring to the fact that images and such assets are omitted from the list of created assets that's printrd to the console. |
Okay, it's all clarified now, thanks a lot for your help! |
Version
3.0.4
Reproduction link
https://github.com/jost-s/vue-cli3-demo
Node and OS info
Node 8.10.0 / npm 6.4.1 / Windows 8.1
Steps to reproduce
.\node_modules\.bin\vue-cli-service build --mode test
./dist
foldernpm run build
./dist
folderWhat is expected?
Create a build including all files
What is actually happening?
Create a build omitting additional images and css files.
At first I ran in to this issue because I deployed an app to a test system where the
NODE_ENV
was set to "test". Building resulted in an incomplete dist folder without images and css files, even though the output said "Building for production...".After trying different combinations of environment variables and webpack modes, it turns out the problem is two-fold:
NODE_ENV = test
, it looks like production mode is used, yet css and image assets are omitted from the build.This issue is related to #2327
The text was updated successfully, but these errors were encountered: