use*_*895 9 gruntjs livereload grunt-contrib-watch
我正在尝试使用livereload和watch.我一直收到消息"致命错误:端口35279已被另一个进程使用".我已经更改了livereload的端口,但没有重新加载.
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
compass: {
dist: {
options: {
cssDir: 'stylesheets',
sassDir: 'stylesheets/sass/',
imagesDir: 'images',
javascriptsDir: 'scripts',
require: ['sass-globbing','modular-scale'],
force: true
}
}
},
cssmin: {
minify: {
expand: true,
cwd: 'stylesheets',
src: ['*.css', '!*.min.css'],
dest: 'stylesheets',
ext: '.min.css'
}
},
watch: {
options: {
livereload: true
},
sass: {
files: 'stylesheets/sass/*.scss',
tasks: ['compass']
},
css: {
files: 'stylesheets/*.css',
tasks: ['cssmin']
},
html: {
files: ['index.html','**/*.css']
}
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.registerTask('default',['compass','watch']);
Run Code Online (Sandbox Code Playgroud)
}
加
<script src="//localhost:1337/livereload.js"></script>
Run Code Online (Sandbox Code Playgroud)
到你想要livereload的页面.1337是您在grunt文件中设置的端口.
options: {
livereload: 1337
},
Run Code Online (Sandbox Code Playgroud)
小智 6
您可以在bash/terminal窗口中手动关闭livereload服务器,如下所示:
curl localhost:35279/kill
Run Code Online (Sandbox Code Playgroud)
更多信息:https://github.com/mklabs/tiny-lr
| 归档时间: |
|
| 查看次数: |
7225 次 |
| 最近记录: |