[英]package javascript app (that uses grunt & browserify) in war
I have a project that consists of a javascript client app and a maven+spring based REST web service. 我有一个项目,该项目由javascript客户端应用和基于maven + spring的REST Web服务组成。
The javascript app is built using browserify and grunt. javascript应用是使用browserify和grunt构建的。 For this reason I am unable to simply place the html/js source in the src/main/webapp directory of my maven based web service project.
因此,我无法简单地将html / js源代码放置在基于Maven的Web服务项目的src / main / webapp目录中。 What really needs to end up in there is the contents of the javascript app's dist directory after browserify/grunt compilation.
最终需要真正完成的工作是在完成browserify / grunt编译后,javascript应用程序的dist目录中的内容。
Question is: how can I set things up so that the javascript app is packaged w/ the web service war (note that this will need to include the grunt/browserify build steps)? 问题是:我该如何进行设置,以使javascript应用与网络服务大战一起打包(请注意,这将需要包括grunt / browserify构建步骤)?
This is possible by using the frontend-maven-plugin for maven. 这可以通过使用Maven的frontend-maven-plugin来实现。 I use it do these steps during every maven build:
我在每个Maven构建过程中使用以下步骤:
I can also trigger gulp build by changing files. 我也可以通过更改文件来触发gulp构建。 Part of my POM (should work similar for grunt):
我的POM的一部分 (咕gr声应该类似):
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>0.0.26</version>
<configuration>
<workingDirectory>src/main/frontend</workingDirectory>
<installDirectory>.</installDirectory>
</configuration>
<executions>
<!-- Config from: https://github.com/eirslett/frontend-maven-plugin -->
<!-- phase optional for all executions: default phase is "generate-resources" -->
<!-- disable some of the following executions to improve build speed -->
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<nodeVersion>v4.1.1</nodeVersion>
<npmVersion>3.3.3</npmVersion>
<nodeDownloadRoot>https://nodejs.org/dist/</nodeDownloadRoot>
<npmDownloadRoot>http://registry.npmjs.org/npm/-/</npmDownloadRoot>
</configuration>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
<execution>
<id>gulp build</id>
<goals>
<goal>gulp</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<srcdir>src/main/frontend</srcdir>
<outputdir>src/main/webapp/resources</outputdir>
<arguments>build</arguments>
</configuration>
</execution>
</executions>
</plugin>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.