admin管理员组文章数量:1326447
I have an angular2 application which uses nodejs server api's. I build the app using nd b, which created the files in dist folder. Where can I specify the production url for the production build, so that all the css, js files loads properly.
And also, whether I need apache server to host these build. Or Can I use node server itself to host it?
Index.html:
<!doctype html>
<html>
<head>
<base href="/">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Demo</title>
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" href="assets/styles/css/custom.css"/>
<script src="assets/vendor/pace/pace.js"></script>
</head>
<body>
<app-root>
<div class="loading"></div>
</app-root>
</body>
</html>
Thanks
I have an angular2 application which uses nodejs server api's. I build the app using nd b, which created the files in dist folder. Where can I specify the production url for the production build, so that all the css, js files loads properly.
And also, whether I need apache server to host these build. Or Can I use node server itself to host it?
Index.html:
<!doctype html>
<html>
<head>
<base href="/">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Demo</title>
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" href="assets/styles/css/custom.css"/>
<script src="assets/vendor/pace/pace.js"></script>
</head>
<body>
<app-root>
<div class="loading"></div>
</app-root>
</body>
</html>
Thanks
Share Improve this question edited Feb 16, 2017 at 11:23 Sanjay Kumar N S asked Feb 15, 2017 at 7:18 Sanjay Kumar N SSanjay Kumar N S 4,7495 gold badges24 silver badges40 bronze badges2 Answers
Reset to default 8By analyzing your html file i am seeing an issue with the <base>
tag.
You need to provide ./
instead of /
which is wrong.
Corrected html document is given below.
<!doctype html>
<html>
<head>
<base href="./"> <!-- use ./ instead of / -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>SHEPHERD SHIELD</title>
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" href="assets/styles/css/custom.css"/>
<script src="assets/vendor/pace/pace.js"></script>
</head>
<body>
<app-root>
<div class="loading"></div>
</app-root>
</body>
</html>
For development and testing purpose you can specify the urls for the css from the dist folder. If you are going for production, then you can copy the minified version of css and js files and put them in style
and js
folders for example, also set the urls in the html file from these folders.
本文标签:
版权声明:本文标题:javascript - Angular2 application build, but file not found while loading the css, js folders - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742212488a2433970.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论