【发布时间】:2016-06-17 21:58:39
【问题描述】:
在使用 spritesmith 处理图像时,我的 gruntfile 中出现了这个奇怪的问题。每个人都遇到过这个吗?
这是我的 gruntfile.. 没什么大不了的,但是当涉及到精灵生成时,问题就出现了......我猜这是内存问题
module.exports = function(grunt) {
var globalConfig = { siteName: 'mysite', };
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
globalConfig: globalConfig, // my variables inititalized here
/* WATCH Configuration */
watch: {
js: {
files: ['wp-content/themes/<%= globalConfig.siteName %>/assets/libs/js/plugins/**/*.js','wp-content/themes/<%= globalConfig.siteName %>/assets/js/app.js'],
tasks: ['concat:dist', 'uglify:dist'],
},
sprite: {
files: ['wp-content/themes/<%= globalConfig.siteName %>/assets/libs/sprite/*.png'],
tasks: ['sprite:dist'],
},
sass: {
files: ['wp-content/themes/<%= globalConfig.siteName %>/assets/css/**/*.scss'],
tasks: ['sass:dist']
},
livereload: {
files: [
'wp-content/themes/<%= globalConfig.siteName %>/*.html',
'wp-content/themes/<%= globalConfig.siteName %>/*.php',
'wp-content/themes/<%= globalConfig.siteName %>/partials/*.php',
'wp-content/themes/<%= globalConfig.siteName %>/functions/*.php',
'wp-content/themes/<%= globalConfig.siteName %>/assets/js/*.{js,json}',
'wp-content/themes/<%= globalConfig.siteName %>/assets/css/**/*.{scss,css}',
'wp-content/themes/<%= globalConfig.siteName %>/assets/images/*.{png,jpg,jpeg,gif,webp,svg}'
],
options: {
livereload: true
}
}
},
/* SASS Configuration */
sass: {
options: {
sourceMap: true,
outputStyle: 'compressed',
},
dist: {
files: {
'wp-content/themes/<%= globalConfig.siteName %>/style.css': 'wp-content/themes/<%= globalConfig.siteName %>/assets/css/main.scss'
}
}
},
/* UGLIFY Configuration */
uglify: {
options: {
mangle: false
},
dist: {
files: {
'wp-content/themes/<%= globalConfig.siteName %>/assets/js/production.min.js': ['wp-content/themes/<%= globalConfig.siteName %>/assets/js/production.js']
}
}
},
/* CONCAT Configuration */
concat: {
options: {
separator: ';',
},
dist: {
src: [
'wp-content/themes/<%= globalConfig.siteName %>/assets/libs/js/plugins/modernizr.js',
'wp-content/themes/<%= globalConfig.siteName %>/assets/libs/js/plugins/html5shiv.js',
'wp-content/themes/<%= globalConfig.siteName %>/assets/libs/js/plugins/jquery.fancybox.js',
'wp-content/themes/<%= globalConfig.siteName %>/assets/libs/js/plugins/jquery.fancybox-media.js',
'wp-content/themes/<%= globalConfig.siteName %>/assets/libs/js/plugins/slick.js',
'wp-content/themes/<%= globalConfig.siteName %>/assets/libs/js/plugins/jquery.mixitup.js',
'wp-content/themes/<%= globalConfig.siteName %>/assets/js/app.js'
],
dest: 'wp-content/themes/<%= globalConfig.siteName %>/assets/js/production.js',
},
},
sprite:{
dist: {
src: 'wp-content/themes/<%= globalConfig.siteName %>/assets/libs/sprite/*.png',
dest: 'wp-content/themes/<%= globalConfig.siteName %>/assets/sprite.png',
destCss: 'wp-content/themes/<%= globalConfig.siteName %>/assets/sprite.css'
}
}
});
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-spritesmith');
grunt.registerTask('default', ['sass:dist', 'concat:dist', 'uglify:dist','sprite:dist', 'watch'] );
// grunt.registerTask('dev-watch', ['concat:dist', 'uglify']);
};
【问题讨论】:
-
在使用
verbose选项执行 grunt 任务后,您能否编辑您的问题并复制/粘贴完整的错误输出:grunt sprite -v? -
看来我明白了...即将发布答案。
标签: gruntjs grunt-contrib-watch grunt-spritesmith