javascript - Firebase - Putting files in multiple directories -


i'm attempting organize project make more maintainable. have large number of html templates , forced put them in public directory. wanted organize this

public directory   views     index.html     register.html     terms.html     privacy.html     support.html   stylesheets     styles.css   scripts     script.js     authentication.js 

but instead looks this

public   index.html   register.html   terms.html   privacy.html   support.html   script.js   authentication.js   styles.css 

here firebase.json file

   {   "firebase": "funmathgame",   "public": "mathgame",   "ignore": [     "firebase.json",     "**/.*",     "**/node_modules/**"   ] } 

here error message get

page not found

the file not exist , there no index.html found in current directory or 404.html in root directory.

why seeing this?

you may have deployed wrong directory application. check firebase.json , make sure public directory pointing directory contains index.html file.

you can add 404.html in root of site replace page custom error page.

the first structure better because separates code. structure works whenever run files in text editor. however, not work whenever deploy firebase.

as example, how reference stylesheets

<head>   <title>frequently asked questions</title>   <link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css'>    </link> <link rel='stylesheet' href='../stylesheets/styles.css'></link> 

in above directory structure, in public/views directory. use .. move 1 directory public directory , forward stylesheets directory. however, here index.html file not in public directory, rather public/views directory.

i have looked @ firebase website, still can't find ideas.

https://www.firebase.com/docs/hosting/guide/full-config.html

if you're willing have /views/index.html in app's address bar, redirect / adding redirects element firebase.json. looks public attribute may incorrect. change firebase.json file to:

{   "firebase": "funmathgame",   "public": "public",   "ignore": [     "firebase.json",     "**/.*",     "**/node_modules/**"   ],   "redirects": [     {       "source": "/",       "destination": "/views/index.html",       "type": 302     }   ] } 

this way, user goes https://funmathgame.firebaseapp.com/ redirected https://funmathgame.firebaseapp.com/views/index.html , relative urls resolved correctly.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -