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

fileReplacements option is missing in the production build #930

Closed
bampakoa opened this issue Jan 28, 2020 · 4 comments · Fixed by #1067
Closed

fileReplacements option is missing in the production build #930

bampakoa opened this issue Jan 28, 2020 · 4 comments · Fixed by #1067
Labels
type: bug Something isn't working

Comments

@bampakoa
Copy link
Contributor

When I execute a production build in an Angular project, Angular Console states that it will run ng build --prod but internally it executes the command, passing the configuration options of the production one by one. Unfortunately, this does not take into account fileReplacements array so I end up with a not so real production version of my app because environment files will not be correctly replaced.

@alexkazantsev
Copy link

@bampakoa did you found any workaround?

@bampakoa
Copy link
Contributor Author

@alexkazantsev no I haven't. I am currently running ng build --prod from the command line.

@alessio-libardi
Copy link

alessio-libardi commented Jul 9, 2020

Hello everyone, I also ran into this problem lately and I have found a momentary workaround.

Workaround:

  1. Press CTRL + P
  2. Type > nx: build and select the first item in the list
  3. Select the project and the configuration you would like to use.

Also, I would like to resolve this issue, i just forked the repo and will try to fix it asap!

@alessio-libardi
Copy link

A quick update, I tried to look into it but couldn't fix it by myself.

The problem seems to be in the way the options are passed to the runner:

// This is not the real code

const options = {
  ...getDefaultConfiguration(environment), // This only return directly usable CLI options    
  ...form.value // The form does only contains CLI options
}

const stringOptions = options.map(option => `--${option.label}=${option.value}`)

this.executeCommand(stringOptions);

So basically the problme is that fileReplacements and other options such as budgets that are present in the angular.json file aren't getting used because they are not configuration that can be used by the CLI directly but can be used only by using the options --configuration=production

@mrmeku i saw that you created much of the ui, do you have any advice?

Probably the best thing we could do would be to also pass the configuration flag before everything else so it can be ovverrided by changing the values of the form.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
4 participants