Created
May 26, 2017 15:56
-
-
Save Camwyn/3ce755f35eb598ec7d34221b044af0ce to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
main: ['release/<%= pkg.version %>'], | |
clean: ['assets/svg/min/*.svg'] | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function (grunt) { | |
grunt.registerTask( 'default', ['svg', 'css', 'js'] ); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Main Grunt task for creating svg iconsmodule.exports = { | |
module.exports = function (grunt) { | |
grunt.registerTask( 'svg', ['clean', 'svgmin', 'svgstore'] ); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
options: { | |
plugins: [ | |
{ | |
removeUselessStrokeAndFill: false | |
} | |
] | |
}, | |
files: { | |
files: [ { | |
expand: true, | |
cwd: 'assets/svg/src', | |
src: ['**/*.svg'], | |
dest: 'assets/svg/min' | |
} ] | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
main: { | |
files: { | |
'assets/svg/symbol-defs.svg': ['assets/svg/min/*.svg'] | |
}, | |
options: { | |
cleanup: true, | |
inheritviewbox: true, | |
prefix : 'icon-', | |
formatting : { | |
indent_with_tabs: true | |
}, | |
svg: { | |
style: "position: absolute; width: 0; height: 0; overflow: hidden;", | |
version: "1.1", | |
xmlns: "http://www.w3.org/2000/svg", | |
}, | |
symbol: { | |
preserveAspectRatio: 'none slice' // helps with some IE bugs | |
} | |
} | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
livereload: { | |
files: ['assets/css/*.css', 'assets/js/src/**/*.js'], | |
options: { | |
livereload: true | |
} | |
}, | |
svg: { | |
files: ['assets/svg/src/**/*svg'], | |
tasks: ['svg', 'css'], | |
options: { | |
debounceDelay: 500 | |
} | |
}, | |
css: { | |
files: ['assets/css/sass/**/*.scss'], | |
tasks: ['svg', 'css'], | |
options: { | |
debounceDelay: 500 | |
} | |
}, | |
js: { | |
files: ['assets/js/src/**/*.js', 'assets/js/vendor/**/*.js'], | |
tasks: ['js'], | |
options: { | |
debounceDelay: 500 | |
} | |
}, | |
}; |
A few notes:
clean.js is essential for preventing any file corruption - not sure why it happens, but sometimes it does (or just fails) without it.
The order is important - clean
then svgmin
, then svgstore
.
For proper creation of the data urls, it's important to run both svg
and css
for any change in either folder in your watch tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Grunt (w/grunt-tasks) for building svg icons