【发布时间】:2016-11-15 05:34:20
【问题描述】:
我正在寻找从
修改构建函数输出的方法ng build --prod
想在 index.html 的 head 部分添加一些引导 css 文件,更改名称 index.html => index.php 等。
怎么做?
【问题讨论】:
标签: templates build hook angular-cli
我正在寻找从
修改构建函数输出的方法ng build --prod
想在 index.html 的 head 部分添加一些引导 css 文件,更改名称 index.html => index.php 等。
怎么做?
【问题讨论】:
标签: templates build hook angular-cli
您可以从源代码自定义实现。这个section 解释了如何继续。
特别是,您可以从addon/ng2/models/webpack-build-common.ts 更改以下行。
new HtmlWebpackPlugin({
template: path.resolve(projectRoot, `./${sourceDir}/index.php`),
chunksSortMode: 'dependency'
})
对于CSS资源,使用Webpack Angular CLI可以直接打包。
编辑
可以在 angular-cli.json 文件中修改应用节点中的键索引。该行应更改为
"index": "index.php",
【讨论】:
我找到了解决这个过程的工作。在 package.json 中修改构建脚本为:
"build": "ng build .......... && mv dist/index.html dist/index.php"
【讨论】: