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

configuration (-c) not working as expected #11184

Closed
nylz opened this issue Jun 9, 2018 · 8 comments
Closed

configuration (-c) not working as expected #11184

nylz opened this issue Jun 9, 2018 · 8 comments
Labels
needs: repro steps We cannot reproduce the issue with the information given

Comments

@nylz
Copy link

nylz commented Jun 9, 2018

Bug Report or Feature Request (mark with an x)

- [ x ] bug report -> please search issues before submitting
- [ ] feature request

Area

- [ x ] devkit
- [ ] schematics

Versions

user@ux-machine:~/coding/angular/ang6test$ ng version
Angular CLI: 6.0.8
Node: 8.11.2
OS: linux x64
Angular: 6.0.4
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package Version

@angular-devkit/architect 0.6.8
@angular-devkit/build-angular 0.6.8
@angular-devkit/build-optimizer 0.6.8
@angular-devkit/core 0.6.8
@angular-devkit/schematics 0.6.8
@angular/cli 6.0.8
@ngtools/webpack 6.0.8
@schematics/angular 0.6.8
@schematics/update 0.6.8
rxjs 6.2.0
typescript 2.7.2
webpack 4.8.3

npm --version
6.1.0

Repro steps

  1. create a clear new project with:
    ng new ang6test

  2. add two new configfiles like:
    environments/environment.simpletest1.ts
    ( containing testvar: 'this is simpletest1')
    environments/environment.simpletest2.ts
    ( containing testvar: 'this is simpletest2')

  3. declare configurations in angular.json like:
    ...
    ,
    "simpletest1": {
    "fileReplacements": [
    {
    "replace": "src/environments/environment.ts",
    "with": "src/environments/environment.simpletest1.ts"
    }
    ]
    },
    "simpletest2": {
    "fileReplacements": [
    {
    "replace": "src/environments/environment.ts",
    "with": "src/environments/environment.simpletest2.ts"
    }
    ]
    }
    ...
    and also the serve-config:
    ...
    "simpletest1": {
    "browserTarget": "ang6test:build:simpletest1"
    },
    "simpletest2": {
    "browserTarget": "ang6test:build:simpletest2"
    }
    ...

  4. now just make it viewable like:
    app.component.ts:
    getTestValue() {
    return environment.testvar;
    }
    app.component.html:

    {{getTestValue()}}

  5. Now test it the following way:
    5.1 start server with following command:
    ng serve -c=simpletest1 -o
    Browser opens with message 'this is simpletest1'
    5.2 stop server and start again with:
    ng serve -c=simpletest2 -o
    Browser opens with message 'this is simpletest1'

See, what I mean? Should be simpletest2 in the second case!

The log given by the failure

No Error Thrown! Starting up normally:
user@ux-machine:~/coding/angular/ang6test$ ng serve -c=simpletest1 -o
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **

Date: 2018-06-09T19:25:09.546Z
Hash: c5c2444f0b09cdf5064f
Time: 8800ms
chunk {main} main.js, main.js.map (main) 9.97 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 227 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 5.22 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 15.6 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 3.3 MB [initial] [rendered]
ℹ 「wdm」: Compiled successfully.
^C
user@ux-machine:~/coding/angular/ang6test$ ng serve -c=simpletest2 -o
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **

Date: 2018-06-09T19:28:29.489Z
Hash: 0b7bafaf2dfd8831e6f0
Time: 8629ms
chunk {main} main.js, main.js.map (main) 9.97 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 227 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 5.22 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 15.6 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 3.3 MB [initial] [rendered]
ℹ 「wdm」: Compiled successfully.

Desired functionality

ng serve -c=configname
should just work as documented.

Mention any other details that might be useful

well, i tried and researched a lot for this. even this clean new project from the scratch makes it reproduceable.

@nylz
Copy link
Author

nylz commented Jun 9, 2018

addon:
uname -a
Linux hostname 4.9.0-6-amd64 #1 SMP Debian 4.9.88-1+deb9u1 (2018-05-07) x86_64 GNU/Linux

@filipesilva
Copy link
Contributor

Heya, I cannot reproduce this locally, can you put up a repro on github where this happens?

@filipesilva filipesilva added the needs: repro steps We cannot reproduce the issue with the information given label Jun 10, 2018
@nylz
Copy link
Author

nylz commented Jun 10, 2018

Hi Filipe,
thank You, for answering.
I pushed my example here: https://github.com/nylz/ang6test

@nylz
Copy link
Author

nylz commented Jun 10, 2018

--- sorry, now pushed completely ---

@phl3x0r
Copy link

phl3x0r commented Jun 11, 2018

If you look in your app.component.ts you are importing simpletest1 directly from the environments:
import { environment } from '../environments/environment.simpletest1';
Just change this to:
import { environment } from '../environments/environment'; and you'll be fine..

@nylz
Copy link
Author

nylz commented Jun 11, 2018

FACEPALM
I am very sorry, that i bothered you with this.
Such things happen, when you rely on thinks like "autoimport" and don't review, what really was imported.
Sorry again. Ticket closed.

@nylz nylz closed this as completed Jun 11, 2018
@phl3x0r
Copy link

phl3x0r commented Jun 11, 2018

No worries :-)

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: repro steps We cannot reproduce the issue with the information given
Projects
None yet
Development

No branches or pull requests

3 participants