【发布时间】:2015-10-31 01:29:41
【问题描述】:
我的 Cloud9-IDE 中有一个 php-Project,我想使用 grunt 和浏览器同步运行,根据:http://fettblog.eu/php-browsersync-grunt-gulp/
我的 Gruntfile.js 看起来像这样:
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-browser-sync');
grunt.loadNpmTasks('grunt-php');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
pkg: grunt.file.readJSON('package.json'),
grunt.initConfig({
sass: {
dist: {
files: {
'assets/css/main.css' : 'assets/css/main.scss',
}
}
},
watch: {
sass: {
files: 'assets/css/layout/*.sass',
tasks: ['sass:dist'],
}
},
php: {
dist: {
options: {
hostname: '0.0.0.0',
port: 8080,
base: '/home/ubuntu/workspace/LifeAqua',
open: true,
keepalive: true
}
}
},
browserSync: {
dist: {
bsFiles: {
src: 'assets/css/main.css'
},
options: {
proxy: '<%= php.dist.options.hostname %>:<%= php.dist.options.port %>',
watchTask: true,
notify: true,
open: true,
}
}
}
});
grunt.registerTask('default', ['php:dist', 'browserSync:dist', 'sass:dist', 'watch']);
};
当我在终端中使用 grunt-command 时,输出如下所示:
我分别测试了 php-、sass- 和 watch-task,它们运行良好。根据输出,一切都开始正常,甚至 browserSync 显然也在“监视文件”。
现在,当我进入预览并在后台更改一些 css 时,我可以在控制台中看到 grunt 正在做一些事情(准确地说:watch 和 sass 任务正在运行)并且 css 正在正确更改。但我只是不能让浏览器同步自动刷新页面,即使根据控制台浏览器同步识别出 css 文件已更改:
我在这里错过了什么?
【问题讨论】:
标签: javascript php gruntjs cloud9-ide browser-sync