5

私はwebappジェネレーターに取り組んでおり、実行後grunt、フォントを正しく表示する機能的なアプリを取得しました。ただし、dist/ディレクトリをチェックインすると、フォント ファイルが取得されません。

ドキュメントにはgruntcommandbuild the application for deploymentと記載されていますが、dist/ディレクトリは自律的ではありません。

Gruntfile.js 構成

私のcopy:distタスクは次のとおりです。

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

したがって、フォントはコピーされますが、含まれているグリフィコンはコピーされませんbower_components/sass-bootstrap/dist/fonts/

ビルドコンテンツ

これが私が走った後に得たすべてですgrunt build

./dist
├── 404.html
├── favicon.ico
├── index.html
├── robots.txt
├── scripts
│   ├── coffee.js
│   ├── plugins.js
│   ├── vendor.js
│   └── main.js
└── styles
    └── main.css

質問

では、すべてのファイルとリソースを含む配置ディレクトリを作成するにはどうすればよいでしょうか?

4

6 に答える 6

12

yeoman 1.1.2 は上記の回答では機能しないようです。

Gruntfile.js を変更して以下を追加します。

copy: {
  dist: {
    files: [{
      expand: true,
      dot: true,
      cwd: '<%= yeoman.app %>',
      dest: '<%= yeoman.dist %>',
      src: [
        '*.{ico,png,txt}',
        '.htaccess',
        '*.html',
        'views/{,*/}*.html',
        'bower_components/**/*',
        'images/{,*/}*.{webp}',
        'fonts/*',
      ]
    }, {
      expand: true,
      cwd: '.tmp/images',
      dest: '<%= yeoman.dist %>/images',
      src: ['generated/*']
    }, {                                                   <--- add this start
        expand: true,
        cwd: '<%= yeoman.app %>/bower_components/bootstrap/fonts',
        dest: '<%= yeoman.dist %>/fonts',
        src: '*.*'
    }]                                                     <--- end add
  },
  styles: {

bower コンポーネントから dist ディレクトリにフォントをコピーする新しいブロックを追加します。sass ディストリビューションを使用する場合は、bootstrap を sass-bootstrap に置き換えます。

于 2014-03-18T13:14:36.280 に答える
5

Sindre が言及したバグは現在修正されています。generator-webapp>= 0.4.2で新しいプロジェクトを開始するか、このパッチを手動で適用することができます。これには、コピー タスクへの 1 つの新しい行のみが含まれます。

    copy: {
        dist: {
            files: [{
                expand: true,
                dot: true,
                cwd: '<%%= yeoman.app %>',
                dest: '<%%= yeoman.dist %>',
                src: [
                    '*.{ico,png,txt}',
                    '.htaccess',
                    'images/{,*/}*.{webp,gif}',
                    'styles/fonts/{,*/}*.*',
                    'bower_components/sass-bootstrap/fonts/*.*' // <-- New line
                ]
            }]
        }
    }
于 2013-09-06T22:28:02.623 に答える
0

それは私のために働いた;)

     copy: {
  dist: {
    files: [{
      expand: true,
      dot: true,
      cwd: '<%= yeoman.app %>',
      dest: '<%= yeoman.dist %>',
      src: [
        '*.{ico,png,txt}',
        '.htaccess',
        '**/*.html',
        'views/**/*.html',
        'images/{,*/}*.{webp}',
        'styles/fonts/{,*/}*.*'
      ]
    }, {
      expand: true,
      cwd: '.tmp/images',
      dest: '<%= yeoman.dist %>/images',
      src: ['generated/*']
    },
        {
        expand: true,
        cwd: '<%= yeoman.app %>/bower_components/bootstrap/fonts',
        dest: '<%= yeoman.dist %>/fonts',
        src: '*.*'
        },
        {
        expand: true,
        cwd: '<%= yeoman.app %>/bower_components/font-awesome/fonts',
        dest: '<%= yeoman.dist %>/fonts',
        src: '*.*'
        }
     /*{
      expand: true,
      cwd: 'bower_components/bootstrap/dist',
      src: 'fonts*//*',
      dest: '<%= yeoman.dist %>'
    }*/]
  },
  styles: {
    expand: true,
    cwd: '<%= yeoman.app %>/styles',
    dest: '.tmp/styles/',
    src: '{,*/}*.css'
  }
},
于 2015-05-26T21:45:23.323 に答える
0

app/bower_components/bootstrap-sass-official/vendor/assets/fonts/bootstrapからフォントをコピーします

アプリ・フォント

application.scssで $icon-font-path を変更します

$icon-font-pathから : "/bower_components/bootstrap-sass-official/vendor/assets/fonts/bootstrap/"

$icon-font-pathへ : "/fonts/"

于 2014-05-15T15:41:26.523 に答える