4

I'm working on a web application which contains multiple SPA (AngularJS) applications, the front end code is TypeScript. I like the VisualStudio feature which combines JavaScript output into one file as I don't want too many JavaScript files. Is there a way to configure it so it still combines the files, but creates a few of them, one per SPA, let's say on folder basis?

I'd preferably like it done by VS, without any external tools.

Thanks

1

1 Answer 1

2

You can for sure. Currently, there are two options which are widely accepted (sorry for lay-out, markup does not seem to love me):

  1. ASP.NET Bundles (in Visual Studio by default, .\App_Start\BundleConfig.cs - for more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862):

    bundles.Add(new ScriptBundle("~/bundles/modernizr")
           .Include("~/Scripts/modernizr-*"));
    
    bundles.Add(new ScriptBundle("~/bundles/bootstrap")
           .Include("~/Scripts/bootstrap/3.0.0/bootstrap.js",
                    "~/Scripts/respond.js"));
    
  2. gulp-concat (external, but quite easy to implement):

    /** bundle and uglify app JS output files. */
    gulp.task('bundle-app-uglify', ['compile-app'], function () {
        // concat and uglify source scripts
        gulp.src(config.allAppJsFiles)
            .pipe(uglify())
            .pipe(concat(config.appBundleNameMinified))
            .pipe(header(config.libraryHeaderTemplate, { 
                organization : config.libraryOrganization,
                url: config.libraryUrl,
                license: config.libraryLicense,
                version: config.libraryVersion,
                currentDate: new Date().toISOString()
            }))
            .pipe(gulp.dest(config.bundleFolder));
    });
    
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.