generator-yeogurt icon indicating copy to clipboard operation
generator-yeogurt copied to clipboard

Static assets copying

Open mathiesha opened this issue 9 years ago • 4 comments

When requiring boostrap-sass is there a way to copy over the font files? or are we to create a gulp copy task?

I just started to use the generator, please excuse me for my ignorance.

mathiesha avatar Jan 16 '16 17:01 mathiesha

Hey @mattts,

Good question! Here is an example of a new task called copy:bootstrapFonts that you can add to the gulp/copy.js file:

'use strict';

import path from 'path';

export default function(gulp, plugins, args, config, taskTarget, browserSync) {
  let dirs = config.directories;
  let dest = path.join(taskTarget);
  let fontDest = path.join(dirs.source, 'fonts');

  // Copy
  gulp.task('copy', () => {
    return gulp.src([
        path.join(dirs.source, '**/*'),
        '!' + path.join(dirs.source, '{**/\_*,**/\_*/**}'),
        '!' + path.join(dirs.source, '**/*.jade')
      ])
      .pipe(plugins.changed(dest))
      .pipe(gulp.dest(dest));
  });

  // Copy over boostrap fonts to `src/fonts` folder
  gulp.task('copy:bootstrapFonts', () => {
    return gulp.src([
        path.join('node_modules/bootstrap-sass/assets/fonts/', '**/*')
      ])
      .pipe(plugins.changed(fontDest))
      .pipe(gulp.dest(fontDest));
  });
}

Then within the your gulpfile, you can add this new task to your serve and build tasks like so:

// Build production-ready code
gulp.task('build', [
  'copy',
  'copy:bootstrapFonts',
  'imagemin',
  'jade',
  'less',
  'browserify'
]);

// Server tasks with watch
gulp.task('serve', [
  'imagemin',
  'copy',
  'copy:bootstrapFonts',
  'jade',
  'less',
  'browserify',
  'browserSync',
  'watch'
]);

Let me know if that works. Cheers :beers:

larsonjj avatar Jan 18 '16 19:01 larsonjj

Awesome works like a charm :clap: ,

I would suggest to add this to the docs if it makes sense.

mathiesha avatar Jan 19 '16 10:01 mathiesha

@mattts, Glad to hear it worked well for you.

I will be writing a guide shortly on how to add Bootstrap to a Yeogurt project. It seems many users are having some trouble implementing Non-CommonJS libs to their projects, so putting some Docs together seems like the next logical step.

I'll keep this issue open until the guide is ready to go, in case any other users find it helpful.

larsonjj avatar Feb 15 '16 23:02 larsonjj

@larsonjj Any updates on the guide yet? Struggling a little to get Bootstrap working in my Yeogurt project!

lyrium avatar Jul 13 '18 04:07 lyrium