Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

404 not found error for glyphicons-halflings-regular.ttf/woff/woff2 #1169

Open
yyw1994 opened this issue Oct 11, 2016 · 10 comments
Open

404 not found error for glyphicons-halflings-regular.ttf/woff/woff2 #1169

yyw1994 opened this issue Oct 11, 2016 · 10 comments

Comments

@yyw1994
Copy link

yyw1994 commented Oct 11, 2016

Hi,all

I just followed the course in Lynda "MEAN Stack and MongoDB Development Techniques", when I have installed "gulp" successfully, and run "gulp serve", the browser throws a "404 not found error" for these resources:

http://localhost:3000/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.woff2
http://localhost:3000/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.woff
http://localhost:3000/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.ttf

the version of my gulp is

CLI version 3.9.1
Local version 3.9.1

the version of my computer is OS 10.11.6

I have read the other solutions and tried but all failed.

@bertramn
Copy link

bertramn commented Oct 16, 2016

Had the same problem today, I fixed it by adding the .tmp/serve/fonts output to gulp/build.js so the fonts task looks like this:

// Only applies for fonts from bower dependencies
// Custom fonts are handled by the "other" task
gulp.task('fonts', function () {
  return gulp.src($.mainBowerFiles())
    .pipe($.filter('**/*.{eot,otf,svg,ttf,woff,woff2}'))
    .pipe($.flatten())
    .pipe(gulp.dest(path.join(conf.paths.tmp, '/serve/fonts/')))
    .pipe(gulp.dest(path.join(conf.paths.dist, '/fonts/')));
});

Also need to properly override the bootstrap icon font location in the src/app/index.scss file like this:

$icon-font-path: '../fonts/' !default;

Technically you can then also remove the "replace font paths" line from gulp\build.js L54. The file would look like this after edits:

  return gulp.src(path.join(conf.paths.tmp, '/serve/*.html'))
    .pipe($.inject(partialsInjectFile, partialsInjectOptions))
    .pipe($.useref())
    .pipe(jsFilter)
    .pipe($.sourcemaps.init())
    .pipe($.ngAnnotate())
    .pipe($.uglify({preserveComments: $.uglifySaveLicense})).on('error', conf.errorHandler('Uglify'))
    .pipe($.rev())
    .pipe($.sourcemaps.write('maps'))
    .pipe(jsFilter.restore)
    .pipe(cssFilter)
    // .pipe($.replace('../../bower_components/bootstrap-sass/assets/fonts/bootstrap/', '../fonts/'))
    .pipe($.cssnano())
    .pipe($.rev())
    .pipe(cssFilter.restore)
    .pipe($.revReplace())
    .pipe(htmlFilter)
   ...

Then just do a gulp serve and it should come good.

@yyw1994
Copy link
Author

yyw1994 commented Oct 21, 2016

well, it doesn't work to mine, if part of the path or file content should be different on my computer?

@bertramn
Copy link

Not sure to be honest, I used the generator to create a project with angluar 1.5.x, normal JavaScript (no ES6) and SASS stylesheet processor. The 2 files I referenced above are generated by yo and placed at the relative path of the project folder. So if your workspace is at ~/workspaces/generated the 1st file is located at ~/workspaces/generated/gulp/build.js and the other file at ~/workspaces/generated/src/app/index.scss.

@AbdelhadiLahlou
Copy link

Hi I had the same problem and changing path in .tmp/serve/index.html is not the solution because it's just a compilation of source/index.html.

The Best SOLUTION that I found is to change path in build.js like this:

.pipe($.replace('../../../bower_components/bootstrap-sass/assets/fonts/bootstrap/', '../fonts/'))

and in index.scss liek this:

$icon-font-path: "../../bower_components/bootstrap-sass/assets/fonts/bootstrap/";

@blowsie
Copy link

blowsie commented Dec 5, 2016

@AbdelhadiLahlou this only works for serve and not serve:dist

@blowsie
Copy link

blowsie commented Dec 5, 2016

@bertramn your solution works for serve:dist and not serve, unless you do step 3

also remove the "replace font paths" line from gulp\build.js

@noob9527
Copy link

@bertramn this works for me

after change
$icon-font-path: '../fonts' !default;
to
$icon-font-path: '../fonts/' !default;

@heshamelmasry77
Copy link

so what is the solution now for this

@sunilkumarkm
Copy link

This solution will work.

In index.scss add $icon-font-path: "../bower_components/bootstrap-sass/assets/fonts/bootstrap/";

In gulp/build.js add .pipe($.replace('../bower_components/bootstrap-sass/assets/fonts/bootstrap/', '../fonts/'))

@Henry0422
Copy link

I vote for sunilkumarkm's solution.

In index.scss, changed from
$icon-font-path: "../../bootstrap-sass/assets/fonts/bootstrap/";
To
$icon-font-path: "../bower_components/bootstrap-sass/assets/fonts/bootstrap/";

In gulp/build.js, changed from
.pipe($.replace('../../bower_components/bootstrap-sass/assets/fonts/bootstrap/', '../fonts/'))
to
.pipe($.replace('../bower_components/bootstrap-sass/assets/fonts/bootstrap/', '../fonts/'))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants