Avatar of Software Squirrel
Software Squirrel
Flag for United States of America asked on

firebase hosting js bundles

I am hosting an app in Firebase hosting.  When I run it locally on localhost:4200, The .js bundles are loaded into my index.html.  When I build and deploy to firebase hosting, it just gets the index.html file but does not get the sources (the .js bundles) Am I missing a step?
JavaScriptAngular

Avatar of undefined
Last Comment
Julian Hansen

8/22/2022 - Mon
Julian Hansen

Look at the source of your deployed app - where is it pointing to.

I am guessing you have a base href in there that is configured on your local machine to a path that is not available on the live site. Simply edit your index.html before deployment and make sure that reference points to the right place.
Software Squirrel

ASKER
Base points to / but that's not the issue.  The right index is showing up.  The problem is that when the index loads it should load with the bundles.js which is the compiled code. It does that on my local host but when I️ push it to the firebase server, the complied .js does not come with it.
Julian Hansen

The right index is showing up.
The index will show - it is the supplementary resources that won't load if the base href is wrong.

Are you saying that the compiled .js is not being copied to the server or it is and it is not loading?

What are you using to push to the server?
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Software Squirrel

ASKER
It is not being pushed to the server as I can see. I can load the index page and view sources. The sources are only the index.  However, when I do the same and load it into the browser in my dev environment under localhost:4200 , I can see the same index.html.  The difference being that when I view sources, I see the compiled .js links and of course I have all the files on my dev server but the point is the .js links show in the browser as referenced on the dev in the browser. On the live web, the references are not there.  I have a .git if it helps.  https://github.com/chrisgore/LoanApp
Software Squirrel

ASKER
BTW - I am using GitHub Desktop to commit and push.  I could just as easily use the terminal too, but that should not matter.
Julian Hansen

The sources are only the index
In the source of the index file should be script references to the bundled scripts - do you see those?
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Software Squirrel

ASKER
The script references are dynamically added at runtime.  So I do see them when index runs on the dev, but they do not add at runtime for live.  In the static index file,
Julian Hansen

Can you post your index.html
Julian Hansen

or a link to your deployed applicatoin
Your help has saved me hundreds of hours of internet surfing.
fblack61
Software Squirrel

ASKER
Julian Hansen

Ok I see what you mean - and that is what came out of the ng build process?

But you say it works locally so what does your local index.html file look like - does not make sense that your local would work if it looks like the deployed one.
Software Squirrel

ASKER
local is the same.  There is not another index so that is it.  At one time there was another index in another folder but, that did not get deployed.  That was also verified by changing the title on each of the index files. They were different. So I know it's the right one.  It is showing the app.component.html file in the index.html (as expected).  There are two components in the app folder.  One is user-profile and the other is core .  The user-profile has the HTML in it that needs to be displayed.  Since the .js files are not there, it's not loading the nested component.  Also, even if it did, since the .js files are not there, nothing would work anyway. It's like it's deploying but not adding the files to be presented at runtime on the live server.  I tried to even put in the url  .../app.js to see if it shows the .js file.  It just directs to the index view so I could not test that theory.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Julian Hansen

When I build your app I get this
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>LoanApp1</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></app-root>

<script type="text/javascript" src="inline.bundle.js"></script><script type="text/javascript" src="polyfills.bundle.js"></script><script type="text/javascript" src="styles.bundle.js"></script><script type="text/javascript" src="vendor.bundle.js"></script><script type="text/javascript" src="main.bundle.js"></script></body>
</html>

Open in new window


That last line is what your online version is missing.
Software Squirrel

ASKER
That is correct.  And it does run correctly on my dev. When I deploy, it does not come over like that.  

Are you saying, when you build it, then open the index.html in something like visual studio code, it has that line in it? Or, only in the browser?
Julian Hansen

Are you saying, when you build it, then open the index.html in something like visual studio code, it has that line in it? Or, only in the browser?
1. Clone repository
2. npm install
3. ng build
4. Browse to dist folder
5. Open index.html with code editor - exactly as I posted above

View source on this page
https://loanapp-0001.firebaseapp.com/

And the  <script> line is missing.

Which means
1. Your deploy process is doing something wierd
2. The line is being removed on the host

I would try and copy that index.html file to the server manually overwriting what is there and test to see if app works.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Software Squirrel

ASKER
That is exactly the process.  And something weird is going on. That's why I thought my deploy package must be doing something wrong or I configured something wrong.  I will copy it manually and see what happens.
Software Squirrel

ASKER
I think I figured it out.  I have a new project and it's using Node.js 9.1.0.  GRPC version is 1.7.1.  Firebase is looking for GRPC 1.4.1.  I guess I need to remove Node and NPM completely and rebuild my app.  I'll post a followup.
Software Squirrel

ASKER
it's working.  The public:  was pointed to the wrong folder.  I changed it to public: "dist" .  Now the only issue is making my user-profile controller to show up
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Software Squirrel

ASKER
so the .js bundles are there now.  The issue now seems to be with a router of some nature.  You can see the error from the app here:  https://loanapp-0001.firebaseapp.com/
ASKER CERTIFIED SOLUTION
Julian Hansen

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Software Squirrel

ASKER
You are correct.  I pieced together two projects and that router was in there.  I am re-working it now.  I have everything going using firebase, but I'm now working to switch it over to firestore.
Software Squirrel

ASKER
There was an issue with the routing.  I fixed that.  Thanks.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Julian Hansen

You are welcome.