I am using angular cli for my angular 2 application. After npm run build, dist folder is created. When I open index.html of dist folder, it cannot find files like inline.bundle.js, polyfills.bundle.js etc. I need to give an absolute path for these files so that I can run my project. Please help.
2 Answers
TO RESOLVE THIS ISSUE OF PROVIDING THE ABSOLUTE PATH
Please use the command below to generate the build of project using angular cli
Command for the dev build
ng build --base-href ./
for the production build
ng build --prod --base-href ./
Base-href is used to notify the path of js file located at.
5 Comments
Keshav Dhawan
core.es5.js:1020 ERROR Error: Uncaught (in promise): SecurityError: Failed to execute 'replaceState' on 'History': A history state object with URL 'file:///Users/keshavdhawan/Documents/sd/dist/' cannot be created in a document with origin 'null' and URL 'file:///Users/keshavdhawan/Documents/sd/dist/index.html'. Error: Failed to execute 'replaceState' on 'History': A history state object with URL 'file:///Users/keshavdhawan/Documents/sd/dist/' cannot be created in a document with origin 'null' and URL 'file:///Users/keshavdhawan/Documents/sd/dist/index.html'.
Keshav Dhawan
This one. ng build --base-href ./
Sahil Kashetwar
I have also run this command its working fine in my case please. is that the error that you are getting in console or terminal. please try to run that command from the root directory
Keshav Dhawan
On terminal it is building fine. I am getting this error on console when I open index.html of dist folder.
Keshav Dhawan
And its just on chrome and firefox. I tested on safari, its working fine. May be a security issue.
ng buildcommand.