本文介绍了在Maven中构建Angular 2项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用Maven构建angular2打字稿项目.有没有一种方法可以将npm install
或ng build
命令包装在pom.xml
文件中?我只想建立那个项目.
I want to build angular2 typescript project using maven. Is there a method to wrap npm install
or ng build
command inside the pom.xml
file? I just want to build that project.
推荐答案
是的.
在package.json
中的scripts
中定义一个build
,我们-我们使用的是webpack-看起来像
In package.json
define a build
in scripts
, ours - we use webpack - looks like
scripts": {
"build": "NODE_ENV=production webpack -p --config webpack.production.config.js",
...
然后在您的POM中使用com.github.eirslett:frontend-maven-plugin
Then use com.github.eirslett:frontend-maven-plugin
in your POM
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>0.0.26</version>
<executions>
<execution>
<!-- optional: you don't really need execution ids,
but it looks nice in your build log. -->
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<nodeVersion>v6.2.2</nodeVersion>
<npmVersion>3.9.5</npmVersion>
</configuration>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<!-- optional: default phase is "generate-resources" -->
<phase>generate-resources</phase>
<configuration>
<!-- optional: The default argument is actually
"install", so unless you need to run some other npm command,
you can remove this whole <configuration> section.
-->
<arguments>install</arguments>
</configuration>
</execution>
<execution>
<id>npm run build</id>
<goals>
<goal>npm</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<arguments>run build</arguments>
</configuration>
</execution>
</executions>
</plugin>
这篇关于在Maven中构建Angular 2项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!