0

Is it possible to actually get the bundles that the framework would generate in runtime, but as physical files when publishing an application?

For instance, if I have 3 files in a bundle: a.js, b.js and c.js (and/or a.min.js, b.min.js, c.min.js), and I publish the website, I want to get only mybundle.js (being its contents the combination in order of a, b and c minified versions).

Is this possible?

zed
  • 2,298
  • 4
  • 27
  • 44

1 Answers1

2

If you want the combined files at build time, you should look into using a task runner like gulp.

Here's a sample from the accepted answer in the linked question:

var gulp = require('gulp'),
    gp_concat = require('gulp-concat'),
    gp_rename = require('gulp-rename'),
    gp_uglify = require('gulp-uglify');

gulp.task('js-fef', function(){
    return gulp.src(['file1.js', 'file2.js', 'file3.js'])
        .pipe(gp_concat('concat.js'))
        .pipe(gulp.dest('dist'))
        .pipe(gp_rename('uglify.js'))
        .pipe(gp_uglify())
        .pipe(gulp.dest('dist'));
});

gulp.task('default', ['js-fef'], function(){});

If you want the combined files after publishing, you can view the page source in your browser and download the bundle.

Community
  • 1
  • 1
jrummell
  • 42,637
  • 17
  • 112
  • 171
  • I need to do this with several bundles, so the last idea of view the page source won't be practical. I'll look into your first approach. I guess I was expecting to find something out of the box in the framework or visual studio publishing settings. Thanks – zed Mar 09 '16 at 19:28
  • @zed, the bundling framework isn't designed for build time, but rather run time, so that's all you can do. – jrummell Mar 09 '16 at 22:59