How to access libraries installed via NPM when running a Firebase app using 'firebase serve'? -
this index.html
<!doctype html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>welcome firebase hosting</title> <link type="text/css" href="node_modules/material-components-web/dist/material-components-web.css"> <script defer src="/__/firebase/4.3.1/firebase-app.js"></script> <script defer src="/__/firebase/4.3.1/firebase-auth.js"></script> <script defer src="/__/firebase/4.3.1/firebase-database.js"></script> <script defer src="/__/firebase/4.3.1/firebase-messaging.js"></script> <script defer src="/__/firebase/4.3.1/firebase-storage.js"></script> <script defer src="/__/firebase/init.js"></script> <script defer src="scripts/app.js" charset="utf-8"></script> </head> <body> ...something... <script src="node_modules/material-components-web/dist/material-components-web.js"></script> <script>mdc.autoinit()</script> </body> </html>
neither stylesheet in line 7 or script inside <body>
loaded.
my project structure follows. included relevant files , directories. public public directory set in firebase.json. don't want keep project in project root directory.
project |-node_modules |-public | |-index.html | |-... | |-firebase.json |-...
my firebase.json file:
{ "database": { "rules": "database.rules.json" }, "hosting": { "public": "public", "ignore": [ "firebase.json", "**/.*" ] } }
firebase hosting doesn't include server-side installation or package management. you'll need upload dependencies part of static assets during deploy.
locally, you'll want place within public folder (the deployed content) or use gulp/grunt task copy them there.
Comments
Post a Comment