Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs gulp字体任务不将roboto fontface文件添加到dist文件夹_Angularjs_Fonts_Gulp - Fatal编程技术网

Angularjs gulp字体任务不将roboto fontface文件添加到dist文件夹

Angularjs gulp字体任务不将roboto fontface文件添加到dist文件夹,angularjs,fonts,gulp,Angularjs,Fonts,Gulp,我正在使用gulp-service:dist构建角度项目,但当索引页面呈现时,所有roboto字体都会出现404错误。看 在github上搜索了许多和,但到目前为止没有一个有效。这是我的文件夹结构和代码 /应用程序/ /bower_组件/roboto fontface/ /bower_组件/roboto fontface/bower.json 这里是完成和相关的字体任务 gulp.task('fonts', function () { return gulp.src($.mainBowerF

我正在使用
gulp-service:dist
构建角度项目,但当索引页面呈现时,所有roboto字体都会出现404错误。看

在github上搜索了许多和,但到目前为止没有一个有效。这是我的文件夹结构和代码

/应用程序/

/bower_组件/roboto fontface/

/bower_组件/roboto fontface/bower.json 这里是完成和相关的字体任务

gulp.task('fonts', function () {
  return gulp.src($.mainBowerFiles())
    .pipe($.filter('**/*.{otf,eot,svg,ttf,woff,woff2}'))
    .pipe($.flatten())
    .pipe(gulp.dest(path.join(conf.paths.dist, '/fonts/')));
});
试验1

gulp.task('copyfonts', function() {
   return gulp.src('../bower_components/roboto-fontface/fonts/**/*.{eot,svg,ttf,woff,woff2}')
   .pipe(gulp.dest(path.join(conf.paths.tmp, '/serve/fonts/')));
});

这行不通

试验2

gulp.task('fonts:dev', function () {
    return gulp.src($.mainBowerFiles())
      .pipe($.filter('**/*.{eot,svg,ttf,woff,woff2}'))
      .pipe($.flatten())
      .pipe(gulp.dest(path.join(conf.paths.tmp, '/serve/fonts/')));
});
但这会将字体awesome和glyphicon.{eot、svg、ttf、woff、woff2}文件添加到serve/fonts/中,这些文件已经在dist/fonts文件夹中

试验3

在主应用程序/bower.json中添加

但仍然不起作用


更新(工作) 上面的工作正常,但这里我需要将正面复制到/font/Roboto文件夹中

如果我没有在
gulp.dest
中添加Roboto文件夹,404错误就会出现,因为它正在fonts/Roboto文件夹中查找字体


在哪里将字体/Roboto文件夹名称更改为默认的/fonts文件夹?

这里是如何实现的。首先将版本更新为roboto fontface 0.7.0,并应用以下步骤

  • /app/bower.json中添加

    "overrides": {
       "roboto-fontface": {
          "main": [
              "css/roboto/less/roboto-fontface.less"
          ]
       }
    }
    
  • 应用程序/索引中。更少

    @import "../../bower_components/roboto-fontface/css/roboto/less/roboto-fontface.less";
    @roboto-font-path: "../../bower_components/roboto-fontface/fonts"; 
    
  • html
    任务中添加以下行

    .pipe($.replace('../../bower_components/roboto-fontface/fonts/', '../fonts/'))
    .pipe($.replace('../../bower_components/fontawesome/fonts/', '../fonts/'))
    
  • 添加一个新的gulp任务copyfonts,该任务将Roboto字体复制到Roboto目录中

    gulp.task('copyfonts', function() {
    return gulp.src($.mainBowerFiles().concat('bower_components/roboto-fontface/fonts/Roboto/*'))
    .pipe($.filter('{Roboto-Thin,Roboto-Medium,Roboto-Bold,Roboto-Regular}.{eot,svg,ttf,woff,woff2}'))
    .pipe($.flatten())
    .pipe(gulp.dest(path.join(conf.paths.dist, '/fonts/Roboto/')));
     });
    
  • 按以下顺序添加这些任务

    gulp.task('war', ['html', 'fonts', 'copyfonts', 'other'], function () {
    
  • // copy Roboto fonts into Roboto Directory
    gulp.task('copyfonts', function() {
      return gulp.src($.mainBowerFiles().concat('bower_components/roboto-fontface/fonts/roboto/*'))
        .pipe($.filter('{Roboto-Black,Roboto-Bold,Roboto-Medium,Roboto-Regular}.{eot,svg,ttf,woff,woff2}'))
        .pipe($.flatten())
        .pipe(gulp.dest(path.join(conf.paths.dist, '/fonts/Roboto')));
    });
    
    "overrides": {
       "roboto-fontface": {
          "main": [
              "css/roboto/less/roboto-fontface.less"
          ]
       }
    }
    
    @import "../../bower_components/roboto-fontface/css/roboto/less/roboto-fontface.less";
    @roboto-font-path: "../../bower_components/roboto-fontface/fonts"; 
    
    .pipe($.replace('../../bower_components/roboto-fontface/fonts/', '../fonts/'))
    .pipe($.replace('../../bower_components/fontawesome/fonts/', '../fonts/'))
    
    gulp.task('copyfonts', function() {
    return gulp.src($.mainBowerFiles().concat('bower_components/roboto-fontface/fonts/Roboto/*'))
    .pipe($.filter('{Roboto-Thin,Roboto-Medium,Roboto-Bold,Roboto-Regular}.{eot,svg,ttf,woff,woff2}'))
    .pipe($.flatten())
    .pipe(gulp.dest(path.join(conf.paths.dist, '/fonts/Roboto/')));
     });
    
    gulp.task('war', ['html', 'fonts', 'copyfonts', 'other'], function () {