2

in our Angular 9 application we have multiple environments configured in angular.json.

We also use @angular-builders/custom-webpack to add some custom plugins that need some input variables based on environment but if I add a custom property to the environment node i get this error:

Data path "" should NOT have additional properties(customPluginConfigForSandboxEnvironment)

"architect": {
   "build": {
     "configurations": {
       "sandbox": {
        "outputPath": ....,
        "customPluginConfigForSandboxEnvironment": {}

Is it possible to do something like this?

In the customWebpackConfig file I can read the outputPath from options

 module.exports = (config, options) => {

and here save my extra configuration, but I prefer to keep all the configurations into the angular.json if it's possible.

Thanks

1
  • did you ever get environment variables available within your @angular-builders/custom-webpack webpack.config.js file? Commented May 20, 2021 at 1:04

1 Answer 1

1

You can use two separate configuration files:

{
  ...
  "projects": {
    "your-app": {
      ...
      "architect": {
        "build": {
          "builder": "@angular-builders/custom-webpack:browser",
          "options": {
            "customWebpackConfig": {
              "mergeRules": {
                "externals": "replace"
              }
            },
            ...
          },
          "configurations": {
            "production": {
              "customWebpackConfig": {
                "path": "./webpack.config.prod.ts"
              },
              ...
            },
            "development": {
              "customWebpackConfig": {
                "path": "./webpack.config.dev.ts"
              }
            }
          },
          ...
        }
      }
    }
  }
}
Sign up to request clarification or add additional context in comments.

1 Comment

Yes we ended up doing this way. Thanks for your contribution!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.