Skip to content

rahulsawant17/netlifytest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Express.js on Netlify Example

Deploy to Netlify

An example of how to host an Express.js app on Netlify using serverless-http. See How to run Express.js apps with Netlify Functions for details.

index.pug simply loads html from the Express.js app using <object>, and the app is hosted at /.netlify/functions/server.

Demo

Check out a working demo of this application at my custom Netlify link.

Get started on Netlify-Express App locally

The most recent information from 2018 confirms that Netlify does not support sub-folders (though there is discussion about adding it to the UI). Therefore all of your project files must exist in the root. It should be noted that while your Netlify routes exist inserver.js, your local routes exist as separate files in the routes subdirectory. Any changes in these files during development must be manually changed in the server.js file to take effect on Netlify.

To get started, ensure you have Node.js installed, then:

npm install
npm start

Entry Point

server-local.js is our entry point. If you have nodemon, run:

nodemon server-local.js

Pug on Netlify

Pug isn't supported on Netlify. Use pug-cli to compile pug into html.

npm install pug-cli
node node_modules/pug-cli/index.js pug/ --out ./views

Be sure the build command on Netlify includes the PUG conversion (set in the `netlify.toml file):

npm install && npm run build && node node_modules/pug-cli/index.js views/ --out ./

Contributors



License & copyright

© 2019 Ethan Miller

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published