Skip to content

Instantly share code, notes, and snippets.

@jesty
Last active August 29, 2015 14:28
Show Gist options
  • Save jesty/78aefd91e7116d4fafb1 to your computer and use it in GitHub Desktop.
Save jesty/78aefd91e7116d4fafb1 to your computer and use it in GitHub Desktop.
Execute NPM during a Maven build.
<!-- In my JEE project I use REACT with Babel and Webpack and I must build the javascript files before prepare the WAR.
I have also configure webpack.config.js to build in a folder under my web application, e.g.:
var DIST_PATH = path.resolve(ROOT_PATH, '../src/main/java/webapp/js/react');
To setup REACT inside my project I used https://github.com/gesposito/bare-webpack
-->
<project>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>some-execution</id>
<phase>prepare-package</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>npm</executable>
<arguments>
<argument>run</argument>
<argument>build</argument>
</arguments>
<workingDirectory>react</workingDirectory>
</configuration>
</plugin>
</plugins>
</build>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment