Search code examples
javascriptnode.jsbuildproductionmaven-profiles

Maven Profile concept in a NodeJS Project without MVN


Hello stakOverFlowers :D
I have a simple NodeJS WebApp that use Lerna to manage the project. So i have a package directory that contains n different projects each ones using different tasks runner tools.

I always use Maven Build Profile in java environment but for this NodeJS project maven will not be used.
So the question is... Is there a way to reproduce the Maven Build Profile concept without using MVN?

In a nutshell i need to use a build profile in nodejs, without using MVN, to customize build for different environments such as Production v/s Development environments.

There's a way to do that? thanks to all


Solution

  • My solution, following the TGW advice, works!! Just install the config module, and create a directory that containing .json files.

    $ npm install config $ mkdir config $ vi config/default.json

    Than if u are on a windows machine, choose your NODE_ENV using NODE_ENV=production and than execute your web app. In your .js file put informations like yours dbConnection host and password.... and to retrieve it use:

    var config = require('config'); var dbConfig = config.get('JsonItem.dbConfig');

    ..more details on https://github.com/lorenwest/node-config