dowjones / gulp-bundle-assets

Create static asset (js, css) bundles from a config file: a common interface to combining, minifying, revisioning and more
MIT License
133 stars 36 forks source link

static files url adjuster #58

Closed julianpaulozzi closed 9 years ago

julianpaulozzi commented 9 years ago

Is there any way to change the css absolutes urls refs on transform? Additionally there is how to specify the output directory to static files (images, fonts, css, js) separately?

chmontgomery commented 9 years ago

Yes.

Firstly, you can modify the path prefixes inside bundle.result.json as part of the call to bundle.results as seen here: examples/custom-transforms/gulpfile.js

Second, you can put each bundle under a custom folder structure by naming your bundle appropriately. Hopefully this example makes it clear: examples/custom-url-paths/bundle.config.js

As far as copying other static files (fonts, images, etc), everything that is possible is shown in this example: examples/copy

All of the above assumes you're outputting all your static files into a single output folder, e.g. /public. If for some reason you want to output files to different top level folders, you'd need to create different gulp tasks using different bundle configs, e.g.:

// gulpfile.js

var gulp = require('gulp'),
  gbundle = require('gulp-bundle-assets');

gulp.task('bundle-js-css', function () {
  return gulp.src('./bundle-js-css.config.js')
    .pipe(gbundle())
    .pipe(gulp.dest('./compiled-assets')); // js, css output folder
});

gulp.task('bundle-font-images', function () {
  return gulp.src('./bundle-font-images.config.js')
    .pipe(gbundle())
    .pipe(gulp.dest('./static-assets')); // images, fonts, etc output folder
});

If these examples don't clear things up please reply back.