angularjs - How to correctly manage fonts with bower / grunt -
on project added bower.json projects use fonts:
- fontawesome
- bootstrap
- roboto-fontface
grunt file generated "yo angular" custom edits. fonts work fine in "grunt serve" development mode don't work when dist build "grunt".
the problem fonts aren't copied dist folder. fix manually changed gruntfile copy:dist fonts. this:
{ expand: true, cwd: "<%= yeoman.app %>/bower_components/bootstrap/dist/fonts", dest: "<%= yeoman.dist %>/fonts", src: ["*.*"] }
my problem libraries css expect fonts on specific folder ( roboto-fontface , bootstrap example expect font in different folders).
so i'll have change gruntfile replace fonts reference on *.css files target right paths. don't know yet how main itch seems "hacky"
bower works css files: automatically added index.html , href correctly replaced when doing dist build. example can upgrade ng-grid project without problems, remove , add new projects. believe works because of bower.json file on ng-grid project contains
"main": ["./ng-grid.css", "./build/ng-grid.js"]
grunt correctly configured understand , add index.html.
but fonts seems solution to modify gruntfile add copy:dist , kind of regex replacement on *css files. but, example, roboto-fontface project bower.json file seems have "main" fonts listed besides css file.
for me seems logical should able configure gruntfile understands "main" parameter has fonts , automatically copies them dist/ , replaces css files correct path.
when add new font project i'll have edit gruntfile, when remove/update fonts.
so, question simple: how can best manage project fonts? best practices? how 'cool kids' doing it?
i ran issue few weeks ago, used yeoman-angular-generator
, had tweak copy:dist well.
in project using 3 separate fonts, font-awesome
, lato
, open-sans
. added font-awesome
via bower other 2 manually downloaded them , placed them under app/fonts
copy: { dist: { files: [{ expand: true, dot: true, cwd: '<%= yeoman.app %>', dest: '<%= yeoman.dist %>', src: [ '*.{ico,png,txt}', '.htaccess', '*.html', 'views/{,*/}*.html', 'images/{,*/}*.{png, jpg, jpeg, gif,webp}', //any new font drop under app/fonts copied dist 'fonts/**' ] }, { expand: true, cwd: '.tmp/images', dest: '<%= yeoman.dist %>/images', src: ['generated/*'] }, { expand: true, cwd: '.', src: 'bower_components/bootstrap-sass-official/assets/fonts/bootstrap/*', dest: '<%= yeoman.dist %>' }, { expand: true, dot: true, cwd: 'bower_components/font-awesome', src: ['fonts/*.*'], dest: '<%= yeoman.dist %>' }] }, styles: { expand: true, cwd: '<%= yeoman.app %>/styles', dest: '.tmp/styles/', src: '{,*/}*.css' } }, //rest of gruntfile...
hope helps!
Comments
Post a Comment