Modify config file during release

Dieterg

Current situation

We have many clients using our client application software. The problem is we need to connect to different REST endpoints. The base URL is always different.

Currently we're using a config.json file which we're manipulating during release. A simple example

config.json

{
  "endpoint": "http://localhost/api"
}

During startup of our application we're doing an HTTP call to get this file. For further API calls we're using the endpoint provided by the config.json file.

Desired outcome

What we really want is this becomes part of our applications instead of doing the HTTP call. We're using webpack to build our application.

In our dataservice layer we want to do something as follows:

import config from './config';

// use config.endpoint;

config.js

export default {
   endpoint: "http://localhost/api"
};

We can override the confg.js file during build. But since we have many clients (+- 30) we don't want to build for each client. We just want one build and modify the config.js file during release with the correct configuration.

Basically we want webpack to ignore the file during build and copy the file to the output folder + inject it in index.html.

I've done some research and I'm not sure how to solve ths issue. Maybe the initial HTTP call isn't that bad afterall?

Edit: the endpoint is just an example, we have more client specific configuration defined in our client app

Dieterg

Ok, this was easier than expected. I simply added a new entry with the config file.

entry: {
   config: "./src/config.ts",
   app: "./src/main.ts"
}

In the UglifyJsPlugin I added an exclude for the config file.

new webpack.optimize.UglifyJsPlugin({
  compress: {
    warnings: false
  },
  exclude: /(config).+/i,
  sourceMap: true
}),

The output is a "readable" config file.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Modify keyboard config file

From Dev

modify KMail config file

From Dev

Modify keyboard config file

From Dev

Release build without config file

From Dev

Modify git config file globally

From Dev

Turn off Logging during Release from Nlog.config

From Dev

Creating a release web.config file

From Dev

bat file to modify web.config setting

From Dev

bat file to modify web.config setting

From Dev

How do I modify config file at runtime

From Dev

Should I replace the customized configuration file during release upgrade?

From Dev

Modify appSettings in the custom config file which is referenced via 'file' attribute

From Dev

Nginx config file overwritten during Elastic Beanstalk deployment?

From Dev

ConfigurationErrorsException/SecurityException/FileIOPermission reading application .config file during NLog instantiation

From Dev

Replace endpoint values in config file during build based on specific environment?

From Dev

Use a Chef recipe to modify a single line in a config file

From Dev

SharePoint 2010 modify web.config file with http handlers

From Dev

Modify the file 'config.inc.php' for XAMPP, PHPMyAdmin & MySQL setup

From Dev

How to modify a key in web.config file through the code?

From Dev

API to modify the machine.config file - 'DbProviderFactories' section can only appear once per config file

From Dev

API to modify the machine.config file - 'DbProviderFactories' section can only appear once per config file

From Dev

Release app during holiday shutdown

From Dev

Skip submodule during maven release

From Dev

No video signal during release upgrade

From Dev

TFS merge during build and release

From Dev

log4net use a different xml config file when in DEBUG mode compared to RELEASE mode

From Dev

VS.NET application - Release vs Debug app.config file

From Dev

Is it possible to find all the config file replacements done during apt-get?

From Dev

How to access and modify the values of .config file with ini format by using c#?

Related Related

  1. 1

    Modify keyboard config file

  2. 2

    modify KMail config file

  3. 3

    Modify keyboard config file

  4. 4

    Release build without config file

  5. 5

    Modify git config file globally

  6. 6

    Turn off Logging during Release from Nlog.config

  7. 7

    Creating a release web.config file

  8. 8

    bat file to modify web.config setting

  9. 9

    bat file to modify web.config setting

  10. 10

    How do I modify config file at runtime

  11. 11

    Should I replace the customized configuration file during release upgrade?

  12. 12

    Modify appSettings in the custom config file which is referenced via 'file' attribute

  13. 13

    Nginx config file overwritten during Elastic Beanstalk deployment?

  14. 14

    ConfigurationErrorsException/SecurityException/FileIOPermission reading application .config file during NLog instantiation

  15. 15

    Replace endpoint values in config file during build based on specific environment?

  16. 16

    Use a Chef recipe to modify a single line in a config file

  17. 17

    SharePoint 2010 modify web.config file with http handlers

  18. 18

    Modify the file 'config.inc.php' for XAMPP, PHPMyAdmin & MySQL setup

  19. 19

    How to modify a key in web.config file through the code?

  20. 20

    API to modify the machine.config file - 'DbProviderFactories' section can only appear once per config file

  21. 21

    API to modify the machine.config file - 'DbProviderFactories' section can only appear once per config file

  22. 22

    Release app during holiday shutdown

  23. 23

    Skip submodule during maven release

  24. 24

    No video signal during release upgrade

  25. 25

    TFS merge during build and release

  26. 26

    log4net use a different xml config file when in DEBUG mode compared to RELEASE mode

  27. 27

    VS.NET application - Release vs Debug app.config file

  28. 28

    Is it possible to find all the config file replacements done during apt-get?

  29. 29

    How to access and modify the values of .config file with ini format by using c#?

HotTag

Archive