2016-04-19 5 views
0

Gruntを使用して最初のプロジェクトを作成しました。 jsファイルを編集した後、変更を適用するにはサーバーを再起動する必要があるため、問題があります。 JADEファイルを編集するときに、再起動サーバーは必要ありません。また別の問題:ファイルを変更した後に自動リフレッシュブラウザを追加するにはどうすればよいですか?juntファイルを編集した後、Gruntが変更を適用します

マイgruntfile:

'use strict'; 

module.exports = function (grunt) { 
    // show elapsed time at the end 
    require('time-grunt')(grunt); 
    // load all grunt tasks 
    require('load-grunt-tasks')(grunt); 

    grunt.initConfig({ 
     reload: { 
      port: 9000, 
      proxy: { 
       host: 'localhost' 
      } 
     }, 
     // Watch Config 
     watch: { 
      files: ['views/**/*','routes/*'], 
      taksks: 'workon reload', 
      options: { 
       nospawn: true // Without this option specified express won't be reloaded 
      }, 
      express: { 
       files: [ 'app.js', '!**/node_modules/**', '!Gruntfile.js' ], 
       tasks: [ 'express:dev' ], 
       options: { 
        nospawn: true // Without this option specified express won't be reloaded 
       } 
      } 
     }, 


     // Clean Config 
     clean: { 
      dist: { 
       files: [{ 
        dot: true, 
        src: [ 
         '.tmp', 
         'dist/*', 
         '!dist/.git*' 
        ] 
       }] 
      }, 
      server: ['.tmp'] 
     }, 
     // Express Config 
     express: { 
      options: { 
       // Override defaults here 
      }, 
      dev: { 
       options: { 
        script: './bin/www' 
       } 
      } 
     }, 
     // Open Config 
     open: { 
      site: { 
       path: 'http://localhost:9000', 
       app: 'chrome' 
      } 
     } 

    }); 

    // Register Tasks 
    // Workon 
    grunt.registerTask('workon', 'Start working on this project.', [ 
     'express:dev', 
     'open:site', 
     'watch' 
    ]); 


    // Restart 
    grunt.registerTask('restart', 'Restart the server.', [ 
     'express:dev', 
     'open:site', 
     'reload', 
     'watch' 

    ]); 


    // Build 
    grunt.registerTask('build', 'Build production ready assets and views.', [ 
     'clean:dist', 
     'concurrent:dist', 
     'useminPrepare', 
     'imagemin', 
     'concat', 
     'cssmin', 
     'uglify', 
     'copy:dist', 
     'rev', 
     'usemin', 
    ]); 

    grunt.loadNpmTasks('grunt-express-server'); 
    grunt.loadNpmTasks('grunt-contrib-watch'); 
    grunt.loadNpmTasks('grunt-open'); 
    grunt.loadNpmTasks('grunt-reload'); 


}; 

EDIT:非常に遅いリロードサーバーページのロード後:

enter image description here

なぜ?

答えて

1
livereload: { 
     options: { 
      livereload: '<%= connect.options.livereload %>' 
     }, 
     files: [ 

     ] 
     } 

私は、時計のこのセクションはあなたに

+0

[OK]を、感謝を助けることができると思います。しかし、サーバーのWebサイトのリロードが遅くなった後。どうして? – lukassz

+0

ブラウザにlivereloadプラグインを使用していますか?私はそれらがconnect plugin.Alsoと衝突する可能性があることを読んでいます。ファイルを指定しようとすることもできます(接続しなくても、すべてを気にしないでください) –

+0

ブラウザにlivereloadプラグインがありません。どのファイルですか? – lukassz

関連する問題