1

I have a build.properties file, which is used by Maven for build purposes. I would like to use the same file and read from it in my front-end application (React-Redux-Webpack). I will provide more info if needed. Any help will be appreciated. Thanks in advance!

1 Answer 1

5

SOLUTION I have reached a solution using an npm module called properties-reader.

  1. Import the module (on the server side, in the webpack config) using
    const PropertiesReader = require('properties-reader');
  2. Read the .properties file again on the server side, in the same file as step #1 (in my case the file is called build.properties)
    const appProperties = PropertiesReader('./build.properties')._properties;
  3. Declare the appProperties in the externals section of Webpack
    externals: { 'appProperties': JSON.stringify(appProperties) },
  4. Just import the appProperties in any of your client .js files like
    var appProperties = require('appProperties') and use it freely

Example of my build.properties structure:
warFilename=customer api_endpoint=xxx.xx.xx.xx version=1.19

I am open for discussion. If you have any suggestions, I would be glad find an even better solution.

Sign up to request clarification or add additional context in comments.

Comments

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.