我正在尝试使用 Grunt 视图运行一个 php Web 服务器,其中 SCSS/CSS 更改被监视并重新编译,因为它们被更改并实时重新加载到 Web 服务器中。目前它正在运行 Web 服务并显示请求,但是当我修改并保存 SCSS 文件时,它根本不会重新编译 CSS 文件。
我在下面包含了我的 Gruntfile.js:
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
compass: {
options: {
config: 'config.rb',
}
},
php: {
options: {
port: 8000,
keepalive: true,
open: true,
base: 'public_html/',
hostname: 'localhost'
},
watch: {
options: {
livereload: 8000
},
scss: {
files: '**/*.scss',
tasks: ['compass'],
options: {
livereload: false
}
},
css: {
files: '**/*.css',
tasks: [],
options: {
livereload: 8000
}
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.loadNpmTasks('grunt-php');
grunt.loadNpmTasks('grunt-contrib-watch');
//grunt.registerTask('default',['watch']);
grunt.registerTask('phpwatch', ['php:watch', 'watch']);
}
如果这有助于调试,这是我运行“grunt phpwatch --verbose”时的输出:
Initializing
Command-line options: --verbose
Reading "Gruntfile.js" Gruntfile...OK
Registering Gruntfile tasks.
Reading package.json...OK
Parsing package.json...OK
Initializing config...OK
Registering "grunt-contrib-compass" local Npm module tasks.
Reading /Users/adam/Sites/sitename/node_modules/grunt-contrib-compass/package.json...OK
Parsing /Users/adam/Sites/sitename/node_modules/grunt-contrib-compass/package.json...OK
Loading "compass.js" tasks...OK
+ compass
Registering "grunt-php" local Npm module tasks.
Reading /Users/adam/Sites/sitename/node_modules/grunt-php/package.json...OK
Parsing /Users/adam/Sites/sitename/node_modules/grunt-php/package.json...OK
Loading "php.js" tasks...OK
+ php
Registering "grunt-contrib-watch" local Npm module tasks.
Reading /Users/adam/Sites/sitename/node_modules/grunt-contrib-watch/package.json...OK
Parsing /Users/adam/Sites/sitename/node_modules/grunt-contrib-watch/package.json...OK
Loading "watch.js" tasks...OK
+ watch
Loading "Gruntfile.js" tasks...OK
+ debug, phpwatch
Running tasks: phpwatch
Running "phpwatch" task
Running "php:watch" (php) task
Verifying property php.watch exists in config...OK
File: [no files]
PHP 5.4.17 Development Server started at Mon Nov 4 16:37:33 2013
Listening on http://sitename.local:8000
Document root is /Users/adam/Sites/sitename/public_html
Press Ctrl-C to quit.
[Mon Nov 4 16:37:40 2013] 127.0.0.1:56330 [200]: /
[Mon Nov 4 16:37:46 2013] 127.0.0.1:56332 [200]: /