我试着观察sass的变化,但是每当我更新sass files.Can时,我都无法在files.Can上看到任何变化,有些请建议我在这里做错了什么,我是刚开始抱怨js的。
{
"name": "test-scss",
"version": "0.1.0",
"devDependencies": {
"bootstrap-sass": "^3.3.7",
"grunt": "^1.0.1",
"grunt-contrib-concat": "^1.0.1",
"grunt-contrib-connect": "^1.0.2",
"grunt-contrib-jshint": "~0.10.0",
"grunt-contrib-nodeunit": "~0.4.1",
"grunt-contrib-sass": "^1.0.0",
"grunt-contrib-uglify": "~0.5.0",
"grunt-contrib-watch": "^1.0.0"
},
"scripts": {
"build-css": "node-sass --include-path scss sass/style.scss css/main.css"
}
}
/// here is my gruntjs file configuration
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
watch: {
options: {
livereload: true
},
sass: {
files: ['**/*.scss'],
task: ['sass']
},
html: {
files: ['*.html']
}
},
sass: {
dist: {
files: {
'css/main.css': 'sass/style.scss'
}
}
},
connect: {
sever: {
options: {
keepalive: true,
hostname: 'localhost',
port: 3003,
base: '.',
open: true,
watch: true,
livereload: true
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.registerTask('default', ['sass', 'watch', 'connect']);
};发布于 2017-03-21 10:38:55
Grunt watch是一个阻塞任务,因此永远无法访问grunt connect。
只有在设置了grunt-contrib-connect时,keepalive: true才会阻塞,否则,只要运行grunt,它就会运行。当grunt watch无限期运行时,不需要强制grunt-contrib-connect为"keepalive“
去修理。
keepalive: false //turn off keepalive将watch阻塞任务移动到最后执行
grunt.registerTask('default', ['sass','connect','watch']); 如果您绝对需要同时运行两个阻塞任务,可以使用像grunt-concurrent https://stackoverflow.com/a/42319772/3656963这样的插件。
或者使用两个命令行分别调用每个任务。
还修正了错误:task: ['sass']到tasks: ['sass']
https://stackoverflow.com/questions/42923535
复制相似问题