编辑
旧问题:grunt监视任务在缩小的css中导致零,因为某些样式被截断
新的诊断:有几个人推送到同一个存储库,我观察到与使用相同的grunt watch设置的缩小文件不同的行为。
结束修改
在我的回购中,我有多个样式表。我使用grunt来监视scss更改并仅修改相关的CSS文件。我最近遇到了一个问题,grunt会在较旧的,未修改的CSS文件中看到修改过的文件。
问题在于:
我从master
开始。
我在命令行中运行grunt
。
我没有对scss文件进行任何更改,但仍然保存文件。
我停止了咕噜声和git status
。
Git在缩小的CSS文件中看到了四个修改。
我保存更改提交并推送到分支。
当我git diff
时,我可以看到grunt已经删除了小数点前面的一些前导零点以获得不透明度。
这是差异的截图。
如果我提交并将这些修改推送到我的分支,我可以继续进行其他更改,只修改相关的CSS缩小文件。 但是将这些更改合并到master
然后再次从master
拉出来,当我在本地运行grunt时,我会看到这些相同的四个" ghost"在缩小的文件中删除相同零的修改。我尝试过更改我的node,sass和grunt版本,但所有不同的版本都有相同的结果!
有没有其他人经历过这个或知道如何阻止咕噜声进行这些更改并通过过度重新编译和提交来破坏回购?
节点版本:5.1.0 sass版本:3.4.19 版本的咕噜声0.4.5 版本的grunt cli:0.1.13
我刚刚将我的节点版本从0.10.33更新为5.1.0
这是我的gruntfile:
module.exports = function(grunt) {
require('time-grunt')(grunt);
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// set notifications that run after other tasks
notify: {
uglify: {
options: {
title: 'Task Complete',
message: 'Uglify finished running',
}
},
sass: {
options: {
title: 'Task Complete',
message: 'Sass finished running',
}
}
},
// concat and minify js task
uglify: {
site: {
files: {
'assets/four/js/site.js': [
'assets/four/js/src/plugins/*.js',
'assets/four/js/src/global.js',
'assets/four/js/src/data/*.js',
'assets/four/js/src/forms/*.js',
'assets/four/js/src/modules/*.js',
'assets/four/js/src/pages/*.js'
],
'assets/four/js/analytics.min.js': ['assets/four/js/src/analytics.js'],
'assets/four/js/social.js': ['assets/four/js/src/social.js']
}
},
pages: {
files: grunt.file.expandMapping(['assets/js/pages/**/*.js', '!assets/js/pages/**/*.min.js'], 'assets/js/pages', {
rename: function(destBase, destPath) {
return destPath.replace('pageassets/js/pages', destBase).replace('.js', '.min.js');
}
})
}
},
//concat and minify scss -> css task
sass: {
options: {
sourceMap: true,
outputStyle: 'compressed'
},
dist: {
files: {
'assets/css/style.css': 'assets/css/scss/style.scss',
'assets/css/old.css': 'assets/css/scss/old.scss',
'assets/css/pages/brand.css': 'assets/css/pages/scss/brand.scss',
'assets/css/pages/custom-design-showcase.css': 'assets/css/pages/scss/custom-design-showcase.scss',
'assets/css/landings.css': 'assets/css/scss/landings.scss',
// 4.0
'assets/four/css/site.css': 'assets/four/css/scss/site.scss',
'assets/four/css/ie.css': 'assets/four/css/scss/ie.scss',
'assets/four/css/interim.css': 'assets/four/css/scss/interim.scss'
}
}
},
// compress images losslessly task
imagemin: {
dynamic: {
options: {
optimizationLevel: 3,
progressive: true,
svgoPlugins: [{removeUselessStrokeAndFill: false}]
},
files: [{
expand: true,
cwd: 'assets/four/img',
src: ['**/*.{png,jpg,gif,svg}'],
dest: 'assets/four/img'
}]
}
},
// watch for changes in repo and run tasks automatically
watch: {
options: {
// Google Extension: https://chrome.google.com/webstore/detail/livereload/jnihajbhpnppcggbcgedagnkighmdlei?hl=en
livereload: true
},
html: {
files: ['templates/default_site/**/*.html']
},
js: {
files: [
'assets/js/*.js',
'assets/four/js/src/global.js',
'assets/four/js/src/plugins/*.js',
'assets/four/js/src/data/*.js',
'assets/four/js/src/forms/*.js',
'assets/four/js/src/pages/*.js',
'assets/four/js/src/modules/*.js',
//dont
'!assets/four/js/*.min.js',
'!assets/four/js/*.js',
'!assets/js/*.min.js',
'assets/js/pages/**/*.js',
'!assets/js/pages/**/*.min.js',
'assets/js/geo/**/*.js',
'!assets/js/geo/**/*.min.js'
],
tasks: ['uglify', 'notify:uglify']
},
sass: {
options: {
livereload: true
},
files: ['assets/css/scss/*.scss', 'assets/four/css/scss/*.scss', 'assets/four/css/scss/pages/*.scss', 'assets/four/css/scss/modules/*.scss', 'assets/css/scss/modules/*.scss', 'assets/css/pages/scss/*.scss'],
tasks: ['sass:dist', 'notify:sass']
},
css: {
files: ['assets/css/*.css', 'assets/four/css/*.css', 'assets/css/pages/*.css']
}
},
});
//load plugins
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-notify');
// to run watch task, enter 'grunt' command line in project DIR
grunt.registerTask('default', ['watch']);
};