Visual Studio 2013 - 如何在 Visual Studio 中將 TypeScript 輸出合併到多個檔案
我正在開發一個網頁應用程式,裡面包含多個 SPA(AngularJS)應用程式,前端程式碼是 TypeScript。我喜歡 Visual Studio 的一個功能,它可以把 JavaScript 輸出合併成一個檔案,因為我不希望有太多 JavaScript 檔案。有沒有辦法設定它,讓它仍然合併檔案,但產生幾個檔案,每個 SPA 一個檔案,比如說按資料夾區分?
我希望最好是由 VS 完成,而不使用任何外部工具。
謝謝
答案#1
你當然可以。目前,有兩個被廣泛接受的選項(抱歉排版不太好,標記語言似乎不太配合我):
ASP.NET 捆綁(在 Visual Studio 中預設位於
.\App_Start\BundleConfig.cs- 關於捆綁的更多資訊,請訪問 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"));gulp-concat(外部的,但相當容易實現):/** 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)); });
