evertonrobertoauler / cli-universal-demo

80 stars 18 forks source link

environment variables #11

Closed scopsy closed 7 years ago

scopsy commented 7 years ago

When rendering a different environment i.e staging, the dist folder contains the code with the correct env data. but when rendering in the server it's compiled with development environment instead. any suggestions on how I can compiel webpack with the correct env ?

thePunderWoman commented 7 years ago

I'm seeing this same behavior. Did you ever solve it, @scopsy?

scopsy commented 7 years ago

@janiukjf I've added the AotPlugin to my webpack config plugins section(not the host replacement path):

    new AotPlugin({
      "mainPath": "main.ts",
      "hostReplacementPaths": {
        "environments/environment.ts": "environments/environment.prod.ts"
      },
      "exclude": [],
      "tsConfigPath": "src/tsconfig.app.json",
      "skipCodeGeneration": true
    })
thePunderWoman commented 7 years ago

Thanks, @scopsy!

thePunderWoman commented 7 years ago

Oh, one more quick question, @scopsy. Where are you importing data.AotPlugin from?

scopsy commented 7 years ago

@janiukjf Oh sorry, that's just from our internal build system. simply import AotPlugin from @ngtools/webpack :)

thePunderWoman commented 7 years ago

@scopsy Awesome! Found it and it works. Thanks again!

longhoang2984 commented 7 years ago

@scopsy where do input the code? :D

scopsy commented 7 years ago

@longhoang2984 Under the plugins array in the webpack config file.