Tariq
Tariq

Reputation: 23

why firebase is not deploying files placed outside public directory?

I've got these three files:

../project/public/index.html
../project/css/style.css
../project/js/func.js

I've linked "style.css" and "func.js" files properly in "index.html" and everything works fine when I test it locally, but when I deploy this project on firebase only "index.html" is deployed and the website does not work properly. If I place all three files in public directory, then all three files are deployed and the website works properly. This is how firebase.json looks

 "hosting": [
    {
      "target": "publicWeb",
      "public": "public",
      "ignore": [
        "firebase.json",
        "**/.*",
        "**/node_modules/**"
      ],
      "rewrites": [
        {
          "source": "**",
          "destination": "/index.html"
        }
      ]
    },

How can I deploy these three files if they are placed in different directories?This is how I've linked files in "index.html"

<script src="../js/func.js"></script>
<link rel="stylesheet" href="../css/style.css">

Upvotes: 2

Views: 1585

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317467

The Firebase CLI will only publish files in the public folder, and nothing outside of it. You should organize all your content under it:

../project/public/index.html
../project/public/css/style.css
../project/public/js/func.js

Use it like this:

<script src="js/func.js"></script>
<link rel="stylesheet" href="css/style.css">

Upvotes: 3

Related Questions