我总是使用Livereload和grunt进行webapps,但突然大约一个月前它停止了工作。我还没有做过与以往不同的事情。这是Livereload的错误还是我错过了什么?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Sitename</title>
<link rel="stylesheet" type="text/css" href="css/app.css">
</head>
<body>
<header>
<div class="logo"></div>
</header>
<section class="content"></section>
<div class="footer">
</div>
<script src="//localhost:35729/livereload.js"></script>
</body>
</html>
和Gruntfile:
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
sass: {
options: {
includePaths: ['bower_components/foundation/scss']
},
dist: {
options: {
outputStyle: 'compressed',
sourceMap: true,
},
files: {
'css/app.css': 'scss/app.scss'
}
}
},
watch: {
grunt: {
options: {
reload: true
},
files: ['Gruntfile.js']
},
sass: {
files: 'scss/**/*.scss',
tasks: ['sass']
}
}
});
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('build', ['sass']);
grunt.registerTask('default', ['build','watch']);
}
控制台中的错误:
[Error] Failed to load resource: Could not connect to the server. (livereload.js, line 0)
控制台:
grunt
Running "sass:dist" (sass) task
Running "watch" task
Waiting...
>> File "scss/app.scss" changed.
Running "sass:dist" (sass) task
Done, without errors.
Completed in 0.773s at Mon Aug 31 2015 17:53:46 GMT+0200 (CEST) - Waiting...
但仍然没有重装。不知何故实时重装服务器没有启动,但实时重载设置为true。有什么想法吗?
答案 0 :(得分:0)
options: {
livereload: true,
},
现在整个Grunt文件:
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
sass: {
options: {
includePaths: ['bower_components/foundation/scss']
},
dist: {
options: {
outputStyle: 'compressed',
sourceMap: true,
},
files: {
'css/app.css': 'scss/app.scss'
}
}
},
watch: {
grunt: {
options: {
reload: true
},
files: ['Gruntfile.js']
},
sass: {
files: 'scss/**/*.scss',
tasks: ['sass'],
options: {
livereload: true,
},
}
}
});
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('build', ['sass']);
grunt.registerTask('default', ['build','watch']);
}