-
Notifications
You must be signed in to change notification settings - Fork 658
Closed
Labels
Description
I'm struggling with getting fontawesome to work with the generated gulp.
I tried to copy the files with a new gulp task in build.js
gulp.task('fontawesome', function() {
return gulp.src('bower_components/fontawesome/fonts/*.*')
.pipe(gulp.dest(paths.dist + '/bower_components/fontawesome/fonts/'));
});
And added the following to the scss file.
$fa-font-path: "../../bower_components/fontawesome/fonts";
@import "../../bower_components/fontawesome/scss/font-awesome.scss";
This works fine for development but breaks in dist (because the relative location of the css file changes. How do I set up the paths correctly? Can I use the fonts
task?
Or in other words. How do I make sure that relative paths to fonts in scss don't break in production?
mikeyfreake
Metadata
Metadata
Assignees
Labels
Projects
Milestone
Relationships
Development
Select code repository
Activity
martyla commentedon Feb 10, 2015
I did something like:
As the fonts should be automatically copied to
dist/fonts
.Also to get the bootstraph glyphicons working for
gulp serve:dist
(as above) I had to replace:with:
Which might be an issue with the generator or I'm just doing something wrong ...
Swiip commentedon Feb 14, 2015
The current font task only copy fonts declared in bower packages. It's the case for bootstrap, I don't know for fontawesome. After that we put the font in a specific directory.
Secondly, we have to replace the font path as you seen to point the right directory in the dist directory structure.
First of all, have you your font files in the dist directory ?
martyla commentedon Feb 14, 2015
Also my bad in my previous comment. I was using an different version of font awesome that didn't have the fonts declared in
bower.json
. In the current version I didn't need to declare anything extra and it magically added everything from./bower_components/font-awesome
.One thing though, is the new font awesome causes an error if the .woff2 font isn't copied to the
./dist/fonts
and I had to add it manually:Swiip commentedon Feb 14, 2015
yeah, woff2 has been added recently to the scripts and not released yet i think
domoritz commentedon Feb 15, 2015
Awesome. It's all working now. The scss import looks like
and I had to add a step to the
html
pipelinebsides commentedon Aug 31, 2015
@domoritz I'm sorry, but how did you achieve to get it working in development? Could you post the complete steps? Thank you
Edit - also, could you say which version of font-awesome was used? Mine here was installed by
bower install fontawesome --save
and it only lists the less/scss in the main bower part.Edit 2 - Ok, for development I just did what you said up here with a little change to the path since mine has a dash, so:
...and now it works on development, but still doesn't for production (gulp build), would you mind helping me around?
domoritz commentedon Aug 31, 2015
Our project is here. https://github.com/uwdata/polestar
Hesesses commentedon Sep 3, 2015
I'm having the same problem, fontawesome works with serve but not included in dist folder after build
claboran commentedon Sep 7, 2015
To get it working for serve:dist a workaround could be found at issue #637.
Best regards,
Chris
disharmonized commentedon Oct 1, 2015
Just in case, for LESS solution will be:
adriangordon1231 commentedon Oct 2, 2015
+1
dannygoncalves commentedon Oct 5, 2015
@claboran i tried that solution but still not sure how to do with font-awesome, how am i supposed to do it? is there any fix or do i have to manually copy the font awesome folder?
danieldiazastudillo commentedon Oct 22, 2015
@dgoncalves1 I've been struggling with this and my solution was:
Make the SCSS imports:
$fa-font-path: "../../bower_components/fontawesome/fonts";
@import "../../bower_components/fontawesome/scss/font-awesome.scss";
With this step you'll see FA icons in dev mode (src).
2.In gulp/build.js there's a task called
html
, you must add this pipe:So far, it's the solution proposed in recipes and everything works great in dev mode BUT when you run the BUILD task it won't copy FA fonts to the dist/fonts folder because they must be declared in your
bower.json
as an override like this:I used a wildcard, inside the file Bootstrap fonts are declared explicitly, that's your choice. Hope this helps.
7 remaining items
poliveira89 commentedon Nov 3, 2015
@olimungo you ONLY edited the
bower.json
?And are you using CSS, LESS or SASS?
olimungo commentedon Nov 3, 2015
@poliveira89 Yes, that's what I like in this solution. And I used Sass with Node.
poliveira89 commentedon Nov 5, 2015
@olimungo but for what I have been looking for on "fonts" task with
gulp-debug
the problem is that the fonts files is not delivered by$.mainBowerFiles()
so when the stream reaches the.pipe($.filter('**/*.{eot,svg,ttf,woff,woff2}'))
it's handling 0(zero) files :/But if I "override" it like you say, in theory the problem will be the same... :/
wonsikin commentedon Nov 19, 2015
@danieldiazastudillo Thanks. Now my project works well after running
build
task.alaksandarjesus commentedon Nov 22, 2015
Its not working my dist folder. My console is throwing this error.
http://localhost:3000/bower_components/font-awesome/fonts/fontawesome-webfont.woff2?v=4.4.0 Failed to load resource: the server responded with a status of 404 (Not Found)
I added in gulp/build.js
.pipe($.replace('../../bower_components/fontawesome/fonts', '../fonts'))
In index.scss
$fa-font-path: '../../bower_components/font-awesome/fonts';
@import '../../bower_components/font-awesome/scss/font-awesome.scss';
Its working fine in serve but not in build
gablabelle commentedon Nov 25, 2015
The recipe seems incomplete because when you build to dist using the the
gulp
command, the font-awesome icon files from its bower package will not be copied to the folder: dist/fonts/You will need to modify the bower.json of your project for the files to be copied:
Then, you will need to modify the gulp/build.js (lines 53 and 54 in the 'html' task) file to make sure that the path to these font-awesome font files is correct:
And finally, you will need to specify the $fa-font-path in you scss file (ie. index.scss):
gulp serve
: fonts are OKgulp
orgulp build
: fonts are OK (build in dist)Hope it helps and that I didn't forget anything. ;-)
codeofsumit commentedon Nov 30, 2015
We installed font awesome via this shim repository:
https://github.com/components/font-awesome
and it works just fine. Probably because their bower.json correctly lists all the font files.
Santino-Wu commentedon Dec 1, 2015
I had the same issue when using
gulp build
task butgulp serve
, and i fixed it by @gablabelle 's solution, thanks!mzellho commentedon Mar 23, 2016
Same for me - @gablabelle 's solution works, many thanks! Just something that took me quite a while, even though it was pretty obvious: make sure to do the replacements in
build.js
aftercodeofsumit commentedon Apr 15, 2016
just tried it again without the shim and yes, the recipe is incomplete, @gablabelle version works!
Correction: it made it work for
gulp serve:dist
- it broke ingulp serve
.Not sure why. Switched back to the shim repo for now.
runmael commentedon Jul 18, 2016
@mzellhofer why do we need to put it after
cssFilter.restore
to work correctly? It actually works when I do that, but I cannot grasp why...xkeshav commentedon Jul 26, 2016
moving down the font awesome replace is not working though
anything else for proper working ? even all my fonts are being copied to dist/fonts folder
zymr-keshav commentedon Jul 29, 2016
thanks @gablabelle ; I have followed your steps but with minimal changes; and now running
gulp serve:dist
also have the fonts and icons here it isbower.json
in build.js
move down the .replace and add one more line for fontawesome
also added otf in gulp.task('font')
McGiogen commentedon Aug 25, 2016
Pay attention to FontAwesome folder name: now it is
fontawesome
and notfont-awesome
(with a little dash) as wrote many times in this issue.