eirslett / frontend-maven-plugin

"Maven-node-grunt-gulp-npm-node-plugin to end all maven-node-grunt-gulp-npm-plugins." A Maven plugin that downloads/installs Node and NPM locally, runs NPM install, Grunt, Gulp and/or Karma.
Apache License 2.0
4.26k stars 869 forks source link

Setting NODE_ENV when running an npm goal #433

Open sshahar1 opened 8 years ago

sshahar1 commented 8 years ago

I'm using the plugin to build angularJS code, with npm and webpack. It works fine, but I need to set NODE_ENV, so some variables would be read from environments.json

I can't figure out if it is possible and how, so I am hoping for your help.

Thanks in advance Sigal

adumat commented 8 years ago

:+1: i need this!

sonirahul commented 6 years ago

This is not working for me. gulp doesn't pick up the environment variables.

sshahar1 commented 6 years ago

Working for webpack. I'm keeping this open for @sonirahul

adumat commented 6 years ago

@sonirahul for me is working, but i'm invoking gulp using npm script from package.json

MatellioRahul commented 6 years ago

@adumat can you please tell me how are you passing environment variables like NODE_ENV?

adumat commented 6 years ago

@MatellioRahul with this definition on pom:

            <execution>
              <id>build</id>
              <phase>generate-resources</phase>
              <goals>
                <goal>npm</goal>
              </goals>
              <configuration>
                <arguments>run build</arguments>
                <environmentVariables>
                  <NODE_ENV>${NODE_ENV}</NODE_ENV>
                </environmentVariables>
              </configuration>
            </execution>

where NODE_ENV is a properties defined in pom properites section and overwritten by profiles of maven.