修改 HTML JS CSS 等文件浏览器自动刷新
module.exports = function (grunt) { var LIVERELOAD_PORT = 35729; // lrSnippet is just a function. // It's a piece of Connect middleware that injects // a script into the static served html. var lrSnippet = require('connect-livereload')({ port: LIVERELOAD_PORT }); // All the middleware necessary to serve static files. var livereloadMiddleware = function (connect, options) { return [ // Inject a livereloading script into static files. lrSnippet, // Serve static files. connect.static(options.base), // Make empty directories browsable. connect.directory(options.base) ]; }; grunt.initConfig({ connect: { client: { options: { port: 9001,hostname: '0.0.0.0', base: 'src/',middleware: livereloadMiddleware } } }, watch: { client: { files: ['src/**/*'], tasks: [], options: { livereload: true }} } }); grunt.loadNpmTasks('grunt-contrib-connect'); grunt.loadNpmTasks('grunt-contrib-watch'); grunt.registerTask('preview', ['connect:client', 'watch:client']);};