2017-02-21 84 views
2

我已经生成角(2)项目,并生成以下的index.html:角CLI项目indes.html

<!doctype html> 
<html> 
<head> 
    <meta charset="utf-8"> 
    <title>FirstAngular</title> 
    <base href="/"> 

    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <link rel="icon" type="image/x-icon" href="favicon.ico"> 
</head> 
<body> 
    <app-root>Loading...</app-root> 
</body> 
</html> 

正如你可以看到没有“脚本”代码的任何JS捆绑。我知道这个项目使用webpack,但我在index.html文件中没有看到它的任何引用。

运行该项目后,一切工作正常。如果有人能告诉我这个“魔术”是怎么发生的,我会爱上它。

谢谢!

回答

1

此index.html仅充当webpack的模板。一旦你做了ng serveng build,实际的index.html将被生成并保存。如果您查看浏览器中的页面源代码,您将看到script标签在那里。

+0

是的我知道,我的问题是这是怎么发生的?这些行为的配置在哪里等等,这个技巧是webpack正在做的还是角CLI? – RiskX