浏览器没有重新加载Grunt Livereload
Browser not reloading with Grunt Livereload
我试图在更改我的文件时添加浏览器的liverload,但浏览器没有重新加载,我不能得到为什么,我做的都像这里描述的,当我打开浏览器grunt,然后当更改index.html
时,在控制台获得
Waiting...
>> File "index.html" changed.
Completed in 0.000s at Wed Jun 03 2015 11:45:24 GMT+0300 (EEST) - Waiting...
>> File "index.html" changed.
Completed in 0.000s at Wed Jun 03 2015 11:54:11 GMT+0300 (EEST) - Waiting...
>> File "index.html" changed.
Completed in 0.000s at Wed Jun 03 2015 12:01:30 GMT+0300 (EEST) - Waiting...
但是浏览器没有重新加载,我做错了什么?也许我错过了什么?我试图谷歌问题,但没有得到任何有用的结果…如果你需要我的文件,就告诉我。谢谢!
我的Gruntfile.js:
module.exports = function(grunt) {
// Load Grunt tasks declared in the package.json file
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
// Configure Grunt
grunt.initConfig({
// Grunt express - our webserver
// https://github.com/blai/grunt-express
express: {
all: {
options: {
bases: ['var''www''megapolis'],
port: 8080,
hostname: "localhost",
livereload: true
}
}
},
// grunt-watch will monitor the projects files
// https://github.com/gruntjs/grunt-contrib-watch
watch: {
all: {
files: '**/*.html',
options: {
livereload: true
}
}
},
// grunt-open will open your browser at the project's URL
// https://www.npmjs.org/package/grunt-open
open: {
all: {
path: 'http://localhost/megapolis/index.html'
}
}
});
// Creates the `server` task
grunt.registerTask('server', [
'express',
'open',
'watch'
]);
};
可能原因是您的grunt-open插件没有配置与express服务器相同的端口。grunt-open插件使用默认的80端口,而express在8080上配置。
尝试添加与express configuration中相同的8080端口:
// grunt-open will open your browser at the project's URL
// https://www.npmjs.org/package/grunt-open
open: {
all: {
path: 'http://localhost:8080/megapolis/index.html'
}
}
相关文章:
- 如何使用url加载程序在webpack中导入多个图像
- 如何在生成下载文件时显示加载动画
- 有没有任何方法可以将控制器从文件加载到ui路由器$stateProvider中
- 无法在通过jQuery的ajax加载的页面中执行javascript
- 无法加载Ace.js编辑器模式和主题(命名空间项目&AMD require.js&grunt
- 从另一个grunt文件加载grunt任务
- Grunt 可以直接从文件对象/数组或 glob 中的“src”值通过 HTTP 加载远程文件
- 我删除了package.json和Gruntfile.js,现在Grunt不会加载依赖项
- 使用requirejs加载一个包含多个类的文件(grunt-concat)
- 使用 grunt requirejs 与单个大型缩小文件连接缓慢时加载问题
- 如何防止在更新多个文件时多次实时重新加载 grunt
- 如何让 Grunt/Watch/LiveReload 在不刷新整页的情况下重新加载 Sass/CSS
- 从节点命令行加载Grunt的JSON文件
- 使用grunt contrib连接和grunt contib手表进行实时重新加载
- grunt sass和js自动加载器
- 在Jasmine测试中通过Grunt加载AngularJS模块
- 是否有可能在grunt中获得实时css/图像重新加载
- Grunt:是否有一种方法来加载一个确定的文件或url,基于当前路径
- 浏览器没有重新加载Grunt Livereload
- Grunt-contrib-watch肝脏负载不重新加载