Sails.js application not refreshing files from assets after start

ε祈祈猫儿з 提交于 2019-12-10 18:07:24

问题


I have a Sails.JS application with Angular.JS front-end. The angular files are stored in /assets/linker and they are injected properly on start. My issue is that when I change css or js file from assets the change doesn't appear on the server, the loaded js file is the same as when the server started. I tried to clear my browser cache and tried in another browser, but still the same. I also tried to run the application with forever -w and nodemon, but still nothing. The application is in dev mode, anyway starting with sails lift --dev does not solve the issue neither.

I have feeling that I miss something in configuration. Is there any way to force reloading of assets?


回答1:


You need to check your Gruntfile configuration. It's where the magic happen in term of linker and livereload.

Specifically, you'll need to look at the watch task and the related tasks. By default it looks like this :

watch: {
  api: {

    // API files to watch:
    files: ['api/**/*']
  },
  assets: {

    // Assets to watch:
    files: ['assets/**/*'],

    // When assets are changed:
    tasks: ['compileAssets', 'linkAssets']
  }
}



回答2:


I found the problem. I made the Angular.js structure with angular generator which adds not only the js structure, but also karma test environment containing shell and bat scripts, karma framework and more.

Building sails application with all these files in watched folder is breaking the refresh functionality. There's no errors in console and nothing in the running application, but the files from assets are not reloaded anymore.

Tip of the day: be careful with the files you have in assets and take a look what does generators generate!




回答3:


I came here looking for livereload, after a little search

Live Reloading

Enabling Live Reload in Your HTML

in current version of Sails v0.10 there is a file for watch task: tasks/config/watch.js



来源:https://stackoverflow.com/questions/19754397/sails-js-application-not-refreshing-files-from-assets-after-start

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!