zan*_*udo 8 javascript maven node.js npm gruntjs
我是maven和frontend-maven-plugin的新手.据我所知,我们可以将此代码添加到pom.xml中以运行grunt,例如:
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<!-- NB! Set <version> to the latest released version of frontend-maven-plugin, like in README.md -->
<version>@project.version@</version>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<nodeVersion>v5.3.0</nodeVersion>
<npmVersion>3.3.12</npmVersion>
</configuration>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<!-- Optional configuration which provides for running any npm command -->
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
<execution>
<id>npm run build</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run build</arguments>
</configuration>
</execution>
<execution>
<id>grunt build</id>
<goals>
<goal>grunt</goal>
</goals>
<configuration>
<arguments>--no-color</arguments>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
我实际上在我的服务器上安装了node和npm,例如:node安装在/ opt/app/trss/nodejs下,npm位于/ opt/app/trss/nodejs/npm下这个pom.xml如何使用该节点,npm安装在我的服务器?谢谢
Mat*_*ion 16
该插件旨在使用节点的本地安装.之前已经请求使用全局安装的版本,但开发人员的立场是该节点不占用太多空间,并且只有在丢失时才会下载.
在本地安装节点允许未全局安装节点或使用不同版本的开发人员构建项目而无需执行任何更复杂的操作mvn clean install.
您可以使用exec插件运行全局安装的npm版本,然后运行grunt.就像是:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.5.0</version>
<executions>
<execution>
<id>run-npm-install</id>
<phase>compile</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>npm</executable>
<arguments>
<argument>install</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>run-grunt</id>
<phase>compile</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>grunt</executable>
<arguments>
<argument>--no-color</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
最后,现在可以跳过 Node 和 npm 安装,详细信息如下:
https://github.com/eirslett/frontend-maven-plugin/issues/768
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<phase>...</phase>
<configuration>
<skip>true</skip>
<nodeVersion>...</nodeVersion>
<npmVersion>...</npmVersion>
</configuration>
</execution>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17987 次 |
| 最近记录: |