【发布时间】:2018-03-13 12:20:06
【问题描述】:
我正在构建一个 Java Web 应用程序,它打包在 WAR 静态资源中。这些静态资源是通过 Angular-CLI 构建的。
Maven 构建通过 Eirslett 的
maven-frontend-plugin
触发 ng 构建,带有 npm 脚本和 npm mojo。
问题是,我想根据 Maven 构建参数使用自定义
base href
,但我没有设法通过环境变量或参数将它传递给 ng。
谁能告诉我如何从 Maven 向 ng 构建传递参数?
代码:
pom.xml
com.github.eirslett
frontend-maven-plugin
node install
generate-resources
install-node-and-npm
npm install
generate-resources
npm
--registry=${npm.internal.registry} --userconfig ${basedir}/.jenkins-npmrc install
npm build
prepare-package
npm
--userconfig ${basedir}/.jenkins-npmrc run-script build
this-does-not-work
npm test
test
npm
run-script test
v8.6.0
5.3.0
.
${node.internal.repo}
${npm.internal.registry}/npm/-/
.
.
package.json
"scripts": {
(...)
"build": "ng build --prod --env=prod --bh=process.env.test --base-href=process.env.test",
(...)
}