使用模块编译TypeScript并捆绑到一个文件

时间:2015-07-30 08:44:03

标签: build typescript

/// <binding ProjectOpened='serve' /> // Macmillan Volunteering Village Gulp file. // This is used to automate the minification // of stylesheets and javascript files. Run using either // 'gulp', 'gulp watch' or 'gulp serve' from a command line terminal. // // Contents // -------- // 1. Includes and Requirements // 2. SASS Automation // 3. Live Serve // 4. Watch Tasks // 5. Build Task 'use strict'; // // 1. Includes and Requirements // ---------------------------- // Set the plugin requirements // for Gulp to function correctly. var gulp = require('gulp'), notify = require("gulp-notify"), sass = require('gulp-sass'), scssLint = require('gulp-scss-lint'), gls = require('gulp-live-server'), // Set the default folder structure // variables styleSheets = 'Stylesheets/', styleSheetsDist = 'Content/css/', html = 'FrontEnd/'; // // 2. SASS Automation // ------------------ // Includes the minification of SASS // stylesheets. Output will be compressed. gulp.task('sass', ['scss-lint'], function () { gulp.src(styleSheets + 'styles.scss') .pipe(sass({ outputStyle: 'compressed' })) .on("error", notify.onError(function (error) { return error.message; })) .pipe(gulp.dest(styleSheetsDist)) .pipe(notify({ message: "Stylesheets Compiled", title: "Stylesheets" })) }); // SCSS Linting. Ignores the reset file gulp.task('scss-lint', function () { gulp.src([styleSheets + '**/*.scss', '!' + styleSheets + '**/_reset.scss']) .pipe(scssLint({ 'endless': true })) .on("error", notify.onError(function (error) { return error.message; })) }); // // 3. Live Serve // ------------- gulp.task('server', function () { var server = gls.static('/'); server.start(); // Browser Refresh gulp.watch([styleSheets + '**/*.scss', html + '**/*.html'], function () { server.notify.apply(server, arguments); }); }); // Task to start the server, followed by watch gulp.task('serve', ['default', 'server', 'watch']); // // 4. Watch Tasks // -------------- gulp.task('watch', function () { // Stylesheets Watch gulp.watch(styleSheets + '**/*.scss', ['scss-lint', 'sass']); }); // // 5. Build Task // -------------- gulp.task('default', ['sass']); 内使用module时,TypeScript编译器将忽略任何tsconfig.json标记并生成常规输出,例如单独文件中的--out个模块。

有没有办法将所有已编译的文件捆绑到一个文件中?

我目前正在尝试使用webpack但无法运行任何加载器。直接运行TypeScript编译器。

1 个答案:

答案 0 :(得分:0)

对于打字稿外部模块包,您可以使用npm包TsProject