Reflect html changes in browser without restarting the express app

前端 未结 3 528
悲&欢浪女
悲&欢浪女 2021-01-12 19:21

I have an express app. I am using swig as the template engine. Is it possible to reflect my HTML changes in the browser when I click refresh. I don\'t want to restart the s

相关标签:
3条回答
  • 2021-01-12 19:50

    There are plenty of tools for this:

    • nodemon
    • supervisor
    • node-hot-reload

    And I'm sure you could find more.

    0 讨论(0)
  • 2021-01-12 20:02

    I got the solution from this link.

    I installed supervisor module as global installation

    npm install supervisor -g
    

    I stated my app like this

    supervisor -e html,js  app.js
    

    Here i am specifying to watch the changes in files with extensions .html and .js. So when these files are changed its automatically reloaded when the next request comes.No restart required.

    0 讨论(0)
  • 2021-01-12 20:04

    You can simply disable swig's caching:

    if (process.env.NODE_ENV !== 'production') {
      swig.setDefaults({ cache: false });
    }
    
    0 讨论(0)
提交回复
热议问题