gpt4 book ai didi

maven - 在 Maven 中构建 Angular 2 项目

转载 作者:搜寻专家 更新时间:2023-10-30 21:30:32 24 4
gpt4 key购买 nike

我想使用 Maven 构建 angular2 typescript 项目。有没有一种方法可以将 npm installng build 命令包装在 pom.xml 文件中?我只想构建那个项目。

最佳答案

是的,我们这样做。

package.json 中,在 scripts 中定义一个 build,我们的 - 我们使用 webpack - 看起来像

scripts": {
"build": "NODE_ENV=production webpack -p --config webpack.production.config.js",
...

然后在你的 POM 中使用 com.github.eirslett:frontend-maven-plugin

        <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 - 在 Maven 中构建 Angular 2 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39585612/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com