当我使用更改它们时,我试图让Grunt重新加载我的js文件grunt-contrib-watch
。这是我的Gruntfile
:
module.exports = function(grunt) {
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
grunt.initConfig({
connect: {
all: {
options:{
port: 9000,
hostname: "0.0.0.0",
base: 'app',
keepalive: true,
middleware: function(connect, options) {
return [
require('grunt-contrib-livereload/lib/utils').livereloadSnippet,
connect.static(options.base)
];
}
}
}
},
open: {
all: {
path: 'http://localhost:<%= connect.all.options.port%>'
}
},
watch: {
options: {
livereload: true
},
js: {
files: ['app/js/**/*.js'],
tasks: ['jshint'],
}
}
});
// Creates the `server` task
grunt.registerTask('server',[
'open',
'livereload-start',
'connect',
'watch'
]);
};
当我更改一个js文件时,没有任何反应。任何帮助都会很棒。
我以前没有尝试过livereloadSnippet
在中间件中使用过,因此我不确定那里可能有什么问题。但是,如果您只需要常规的LiveReload设置,则可以使用插件livereload
提供的选项grunt-contrib-connect
:
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
grunt.initConfig({
connect: {
all: {
options:{
port: 9000,
hostname: '0.0.0.0',
base: 'app',
keepalive: true,
livereload: true,
open: true
}
}
},
watch: {
options: {
livereload: true
},
js: {
files: ['app/js/**/*.js'],
tasks: ['jshint']
}
}
});
grunt.registerTask('server',[
'connect',
'watch'
]);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句