diff --git a/gulp-rev-replace/gulp-rev-replace-tests.ts b/gulp-rev-replace/gulp-rev-replace-tests.ts index 57515c9ac..e7c5d9c18 100644 --- a/gulp-rev-replace/gulp-rev-replace-tests.ts +++ b/gulp-rev-replace/gulp-rev-replace-tests.ts @@ -9,13 +9,9 @@ import rev = require('gulp-rev'); import useref = require('gulp-useref'); gulp.task("index", () => { - var userefAssets = useref.assets(); - return gulp.src("src/index.html") - .pipe(userefAssets) // Concatenate with gulp-useref + .pipe(useref()) // Concatenate with gulp-useref .pipe(rev()) // Rename the concatenated files - .pipe(userefAssets.restore()) - .pipe(useref()) .pipe(revReplace()) // Substitute in new filenames .pipe(gulp.dest('public')); }); diff --git a/gulp-typescript/gulp-typescript-tests.ts b/gulp-typescript/gulp-typescript-tests.ts index 3dd743188..5abd5a152 100644 --- a/gulp-typescript/gulp-typescript-tests.ts +++ b/gulp-typescript/gulp-typescript-tests.ts @@ -54,3 +54,9 @@ gulp.task('scripts', function () { return gulp.src('lib/*.ts') .pipe(typescript(tsProject, undefined, typescript.reporter.fullReporter())); }); + +gulp.task('default', function () { + return gulp.src('src/**/*.ts') + .pipe(typescript()) + .pipe(gulp.dest('built/local')); +}); diff --git a/gulp-typescript/gulp-typescript.d.ts b/gulp-typescript/gulp-typescript.d.ts index 7b16d0a5a..84d4b5d9c 100644 --- a/gulp-typescript/gulp-typescript.d.ts +++ b/gulp-typescript/gulp-typescript.d.ts @@ -6,11 +6,11 @@ /// declare module "gulp-typescript" { - function GulpTypescript(params: GulpTypescript.Params, filters?: GulpTypescript.FilterSettings, reporter?: GulpTypescript.Reporter): GulpTypescript.CompilationStream; + function GulpTypescript(params?: GulpTypescript.Params, filters?: GulpTypescript.FilterSettings, reporter?: GulpTypescript.Reporter): GulpTypescript.CompilationStream; module GulpTypescript { - export function createProject(params: Params): Project; - export function createProject(file: string, params: Params): Project; + export function createProject(params?: Params): Project; + export function createProject(file: string, params?: Params): Project; export function filter(filters: FilterSettings): CompilationStream; interface Params { declarationFiles?: boolean; diff --git a/gulp-useref/gulp-useref-tests.ts b/gulp-useref/gulp-useref-tests.ts index 95c35662d..6af7aaab8 100644 --- a/gulp-useref/gulp-useref-tests.ts +++ b/gulp-useref/gulp-useref-tests.ts @@ -1,15 +1,76 @@ /// /// +/// +/// +/// +/// +/// +/// +/// -import gulp = require('gulp'); -import useref = require('gulp-useref'); - -gulp.task('default', () => { - var assets = useref.assets(); +import * as gulp from 'gulp'; +import * as useref from 'gulp-useref'; +// Usage +gulp.task('default', function () { return gulp.src('app/*.html') - .pipe(assets) - .pipe(assets.restore()) .pipe(useref()) .pipe(gulp.dest('dist')); }); + +gulp.task('default', function () { + return gulp.src('app/*.html') + .pipe(useref({ searchPath: '.tmp' })) + .pipe(gulp.dest('dist')); +}); + +import * as gulpif from 'gulp-if'; +import uglify = require('gulp-uglify'); +import minifyCss = require('gulp-minify-css'); + +gulp.task('html', function () { + return gulp.src('app/*.html') + .pipe(useref()) + .pipe(gulpif('*.js', uglify())) + .pipe(gulpif('*.css', minifyCss())) + .pipe(gulp.dest('dist')); +}); + + +// Transform Streams +import * as sourcemaps from 'gulp-sourcemaps'; +import lazypipe = require('lazypipe'); + +gulp.task('default', function () { + return gulp.src('index.html') + .pipe(useref({}, lazypipe().pipe(sourcemaps.init, { loadMaps: true })())) + .pipe(sourcemaps.write('maps')) + .pipe(gulp.dest('dist')); +}); + + +// options.additionalStreams +import * as ts from 'gulp-typescript'; + +// create stream of virtual files +var tsStream = gulp.src('src/**/*.ts') + .pipe(ts()); + +gulp.task('default', function () { + // use gulp-useref normally + return gulp.src('src/index.html') + .pipe(useref({ additionalStreams: [tsStream] })) + .pipe(gulp.dest('dist')); +}); + + +// options.transformPath +gulp.task('default', function () { + return gulp.src('app/*.html') + .pipe(useref({ + transformPath: function(filePath) { + return filePath.replace('/rootpath','') + } + })) + .pipe(gulp.dest('dist')); +}); diff --git a/gulp-useref/gulp-useref.d.ts b/gulp-useref/gulp-useref.d.ts index b1628aa5f..86011015c 100644 --- a/gulp-useref/gulp-useref.d.ts +++ b/gulp-useref/gulp-useref.d.ts @@ -1,4 +1,4 @@ -// Type definitions for gulp-useref v1.2.0 +// Type definitions for gulp-useref v3.0.0 // Project: https://github.com/jonkemp/gulp-useref // Definitions by: Tanguy Krotoff // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -6,20 +6,19 @@ /// declare module 'gulp-useref' { - interface IAssetsOptions { + interface Options { searchPath?: string | string[]; + base?: string; + noAssets?: boolean; noconcat?: boolean; + additionalStreams?: Array; + transformPath?: (filePath: string) => void; } - interface IAssetsStream extends NodeJS.ReadWriteStream { - restore(): NodeJS.ReadWriteStream; + interface Useref { + (options?: Options, ...transformStreams: NodeJS.ReadWriteStream[]): NodeJS.ReadWriteStream; } - interface IUseref { - (options?: any): NodeJS.ReadWriteStream; - assets(options?: IAssetsOptions): IAssetsStream; - } - - var useref: IUseref; + var useref: Useref; export = useref; }