为什么Yeoman构建过程中没有包含/styles/fonts文件夹?

8
在运行grunt build后,我在dist/styles目录下没有fonts文件夹。我做错了什么吗?
以下是我的Gruntfile.js内容:
    compass: {
        options: {
            sassDir: '<%= yeoman.app %>/styles',
            cssDir: '.tmp/styles',
            imagesDir: '<%= yeoman.app %>/../images',
            javascriptsDir: '<%= yeoman.app %>/scripts',
            fontsDir: '<%= yeoman.app %>/../styles/fonts',
            importPath: 'app/bower_components',
            relativeAssets: true,
        },
        dist: {
            options: {
                imagesDir: '<%= yeoman.dist %>/images',
                fontsDir: '<%= yeoman.app %>/../styles/fonts'
            }
        },
        server: {
            options: {
                debugInfo: true
            }
        }
    },

不确定您的项目布局,但是dist下的fontsDir应该是yeoman.dist而不是yeoman.app吗? - dc5
尝试过了,仍然没有字体目录。dist.options 实际上最初是空的。这只是我尝试的东西。 - Daniel Birowsky Popeski
1个回答

14

compass 任务不负责将字体从 app 文件夹复制到 dist 文件夹。这个任务由 copy 任务处理,通常是这样的:

copy: {
  dist: {
    files: [{
      expand: true,
      dot: true,
      cwd: '<%= yeoman.app %>',
      dest: '<%= yeoman.dist %>',
      src: [
        '*.{ico,png,txt}',
        '.htaccess',
        'bower_components/**/*',
        'images/{,*/}*.{gif,webp}',
        'styles/fonts/*' // <-- Where fonts are copied.
      ]
    }, {
      expand: true,
      cwd: '.tmp/images',
      dest: '<%= yeoman.dist %>/images',
      src: [
        'generated/*'
      ]
    }]
  }
}

1
好的,它已经可以工作了。 :} 它最初为什么没有设置,有什么原因吗? - Daniel Birowsky Popeski
大多数生成器都已经默认包含了这个功能。你用的是哪一个? - passy
奇怪的是,Backbone生成器。 - Daniel Birowsky Popeski
直到我找到了这个解决方案,我才知道自己做错了什么。 - eli

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接