0
我正在使用Grunt監視我的sass/js文件中的更改並將它們編譯到我的公用文件夾中。我已經設置了一個可以正常工作的Livereload功能,但是當我編譯我的js時,Livereload會重新加載我的頁面2次,這很煩人。我認爲這是因爲我有多個在手錶中創建的JS文件(concat,minify)。因爲(現在)我只有一個js文件(uglify.js)和一個css文件(main.css),所以我認爲只重新加載公用文件夾中的更改可能是個不錯的主意。但我看不出如何工作。僅在公用文件夾中更改時重新裝載
這是我目前gruntfile的外觀:
module.exports = function (grunt) {
// Project configuration.
grunt.initConfig({
watch: {
watch_js_files: {
files: ['js/*.js'],
tasks: ['concat', 'minified', 'uglify'],
},
watch_sass_files: {
files: ['css/*.scss'],
tasks: ['sass'],
}
},
connect: {
server: {
options: {
open: true,
keepalive: true,
hostname: 'localhost',
port: 8080,
base: ''
}
}
},
concat: {
dist: {
src: ['js/*.js'],
dest: 'js/min/concat.js'
},
},
minified: {
files: {
src: ['js/min/concat.js'],
dest: 'js/min/minified.js'
},
},
uglify: {
my_target: {
files: {
'public/js/uglify.js': ['js/min/minified.jsconcat.js']
}
}
},
sass: {
dist: {
files: {
'public/css/main.css': 'css/*.scss'
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-minified');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-connect');
};