Solvedangular cli Incorrect JS paths when ng build -prod is deployed in a subfolder
✔️Accepted Answer
When you're deploying to non-root path within a domain, you'll need to manually update the <base href="/">
tag in your dist/index.html
.
In this case, you will need to update to <base href="/angular2-test/">
I believe.
Other Answers:
Don't be sorry, this is a common scenario and not so easy to identify. Next time someone has the same problem they will find your issue :)
@filipesilva You give me a clue... ng build -prod --base-href \"/mysubfolder/\"
works in my server without change original <base href="/">
in my index.html
for continue developing.
You can view the result here: http://foobar.cf/calculator
Thanks a lot!
Solved the issue using ng build --prod --base-href "https://kartik1607.github.io/angularHeader/" -d "/angularHeader"
command.
Having the same issue as @chandresh87 - ng build --prod --base-href "/mypath/"
allows the app to load, but still 'assets' are unable to load because they are looked for in root.
But --aot=false
and -d
didn't help me.
What's the best practice here? surely I'm not expected to rewrite all urls to match the production setup.
angular-cli: 1.0.0-beta.5
node: 4.4.5
os: win32 x64
Browser log when accessing http://datamatic.co/angular2-test/:
Files are loaded relative to the domain, not the folder