gpt4 book ai didi

javascript - Grunt LiveReload 未显示

转载 作者:行者123 更新时间:2023-12-03 10:11:10 24 4
gpt4 key购买 nike

我有一个关于 Grunt 的 livereload 的菜鸟问题。我将监视任务配置为 livereload: true我在页面底部添加了标签,当我将浏览器指向 localhost:port_number_i_can't_remember 时,它会显示一个带有 .js 服务器的页面,我猜...

我如何使用 livereload 重新加载我正在处理的 html。我必须将浏览器指向哪里?我正在使用 sublime3 并添加了 livereload 包。我也使用括号,在两者之间打开/关闭。

grunt 文件:

module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),

sass: {
options: {
includePaths: ['sass/**/*.scss']
},
dist: {
options: {
outputStyle: 'compressed',
sourceMap: true
},
files: {
'css/materialize.css': 'sass/materialize.scss'
}
}
},

watch: {
grunt: {
options: {
livereload: true
},
files: [
'css/*.css',
'*.html'
]
},

sass: {
files: 'sass/**/*.scss',
tasks: ['sass']
},

}

});

grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-contrib-watch');

grunt.registerTask('build', ['sass']);
grunt.registerTask('default', ['build', 'watch']);

}

我在这里做错了什么?

最佳答案

启用它的方法有多种,official wiki 中列出了它们。 .

最简单的是第一个,包括

<script src="//localhost:35729/livereload.js"></script>

之前</body>在您的 HTML 页面中。

如果您对其中一种方法有任何疑问,请相应更新问题

关于javascript - Grunt LiveReload 未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30107958/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com