我的 Gruntfile.js 中有这个设置
module.exports = function(grunt) {
grunt.initConfig({
less: {
development: {
options: {
compress: false,
yuicompress: false,
optimization: 0
},
files: {
// target.css file: source.less file
"assets/css/main.css": "assets/css/main.less"
},
}
},
watch: {
styles: {
// Which files to watch (all .less files recursively in the less directory)
files: ['assets/css/*.less', 'assets/less/*.less'],
tasks: ['less'],
},
// Live reload CSS
css: {
files: ['assets/css/*.css'],
options: {
nospawn: true,
interrupt: false,
livereload: true,
},
},
},
});
// Watch
grunt.loadNpmTasks('grunt-contrib-watch');
// Less Complile
grunt.loadNpmTasks('grunt-contrib-less');
grunt.registerTask('default', ['less','watch']);
};
我的样式表是这样加载的:
<link rel="stylesheet" href="http://project.dev/wp-content/themes/project/style.css">
每当我更改 css 文件时,我都会在浏览器中收到此 url 的 404 错误
http://project.dev/assets/css/main.css?livereload=1392748371895
这当然是正确的,因为 css 文件位于:
http://project.dev/wp-content/themes/project/assets/css/main.css
如何获得实时重新加载以获取正确的 URL?