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
SOLUTION I have reached a solution using an npm module called properties-reader.
- Import the module (on the server side, in the webpack config) using
const PropertiesReader = require('properties-reader'); - 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; - Declare the appProperties in the externals section of Webpack
externals: { 'appProperties': JSON.stringify(appProperties) }, - 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.