在子文件夹中使用所有脚本进行"ng build" [英] 'ng build' with all scripts in subfolder
问题描述
现在可以用ng build
来获得不平坦的项目结构,所以代替这个:
It is now possible, to get not flat structure of project with ng build
, so instead of this:
index.html
main.bundle.js
styles.bundle.js
...
我希望脚本位于子文件夹中
I want scripts to be in subfolder
*index.html
scripts/main.bundle.js
scripts/styles.bundle.js
...*
我找到了一个与此相关的主题:"ng build"将脚本移动到子文件夹,但雇用的解决方案是将eject
项目从cli
投影到webpack
,但使用Angular 7
时将不再可用,并且现在已禁用ng eject
:
I found a topic about this: 'ng build' move scripts to subfolder but hire the solutions is to eject
project from cli
into webpack
but with Angular 7
this is not longer available and ng eject
is now disabled:
'eject'命令已被禁用,将被完全删除 在8.0中.新的配置格式为以下方面提供了更大的灵活性: 修改工作空间的配置而不会弹出.
The 'eject' command has been disabled and will be removed completely in 8.0. The new configuration format provides increased flexibility to modify the configuration of your workspace without ejecting.
有几个项目可以与新项目结合使用 配置格式,可提供无需弹出即可弹出的好处 维护费用.这样的项目之一就是ngx-build-plus,可在此处找到: https://github.com/manfredsteyer/ngx-build-plus
There are several projects that can be used in conjuction with the new configuration format that provide the benefits of ejecting without the maintenance overhead. One such project is ngx-build-plus found here: https://github.com/manfredsteyer/ngx-build-plus
Angular提供了有关angular.json
文件租用的非常差的文档 https://github .com/angular/angular-cli/wiki/angular-workspace ,因此在实际的项目问题中很难使用此配置文件.
Angular provide very poor documentation of angular.json
file hire https://github.com/angular/angular-cli/wiki/angular-workspace so it's difficult to use this config file in real project problems.
推荐答案
您不能使用 ng build
命令,您可以通过依次使用以下命令来做到这一点.
You cannot do that by using the ng build
command alone, you can do it by using the following the commands one after the other.
ng build --output-path="dist/scripts" --deployUrl="scripts/"
和
move "dist\scripts\index.html" "dist"
考虑到您正在使用Windows,最后一个命令可以正常工作(仅仅是复制/粘贴,魔术是由--deployUrl
命令完成的.)
The last command works considering that you are using windows (is just a copy/paste, the magic is done by the --deployUrl
command).
这篇关于在子文件夹中使用所有脚本进行"ng build"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!