Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 角度2:将index.html作为自定义位置放置_Angular_Angular Cli - Fatal编程技术网

Angular 角度2:将index.html作为自定义位置放置

Angular 角度2:将index.html作为自定义位置放置,angular,angular-cli,Angular,Angular Cli,生成后是否可以将index.html放在自定义位置? (我需要它,以便将index.html放在django的templates文件夹中) 当前它位于dist文件夹的根目录中 如果我弹出angular应用程序,我就能做到这一点 new HtmlWebpackPlugin({ "template": "./src/index.html", "filename": "../templates/main/index.html", ... }) 是否可以在angul

生成后是否可以将index.html放在自定义位置? (我需要它,以便将index.html放在django的templates文件夹中) 当前它位于dist文件夹的根目录中

如果我弹出angular应用程序,我就能做到这一点

new HtmlWebpackPlugin({
      "template": "./src/index.html",
      "filename": "../templates/main/index.html",
      ...
})
是否可以在angular-cli.json中执行此操作? 或者我必须定义一个后期构建步骤? (实际上,我尝试定义了一个后期构建步骤,从dist文件夹到定制位置,但dist文件夹位置是从.angular-cli.json派生的,后期构建是package.json的attr)


感谢您的帮助

您可以修改
.angular cli.json
并将路径放入
outDir
属性中

"outDir": "templates/main",
这将更改
build
目录

编辑:为此,您需要定义一个npm脚本

"build":" "ng build"
并添加后期生成脚本:

"postbuild": "copy ./build/index.html ./yourFolder/",

postBuild
build
完成后运行。

是,您还必须移动所有生成的文件。这将更改整个输出目录。我需要输出目录是相同的,只需将index.html复制到其他地方,而不是所需的chagesYes,我尝试了与我在问题中提到的相同的方法。但问题是,拷贝的源位置是由angular cli中的“outputDir”派生的。除了硬编码,我看不到任何其他选择。