本文整理汇总了TypeScript中gulp-if.default方法的典型用法代码示例。如果您正苦于以下问题:TypeScript gulp-if.default方法的具体用法?TypeScript gulp-if.default怎么用?TypeScript gulp-if.default使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gulp-if
的用法示例。
在下文中一共展示了gulp-if.default方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getOptimizeStreams
export function getOptimizeStreams(options?: OptimizeOptions):
NodeJS.ReadWriteStream[] {
options = options || {};
const streams = [];
// compile ES6 JavaScript using babel
if (options.js && options.js.compile) {
streams.push(gulpif(/\.js$/, new JSDefaultCompileTransform()));
}
// minify code (minify should always be the last transform)
if (options.html && options.html.minify) {
streams.push(gulpif(
/\.html$/,
new HTMLOptimizeTransform(
{collapseWhitespace: true, removeComments: true})));
}
if (options.css && options.css.minify) {
streams.push(
gulpif(/\.css$/, new CSSMinifyTransform({stripWhitespace: true})));
// TODO(fks): Remove this InlineCSSOptimizeTransform stream once CSS
// is properly being isolated by splitHtml() & rejoinHtml().
streams.push(gulpif(
/\.html$/, new InlineCSSOptimizeTransform({stripWhitespace: true})));
}
if (options.js && options.js.minify) {
streams.push(gulpif(/\.js$/, new JSDefaultMinifyTransform()));
}
return streams;
};
示例2: function
gulp.task('html', function () {
return gulp.src('app/*.html')
.pipe(useref())
.pipe(gulpif(f => f.path.endsWith('.js'), uglify()))
.pipe(gulpif(f => f.path.endsWith('.css'), minifyCss()))
.pipe(gulp.dest('dist'));
});
示例3: function
gulp.task('html', function () {
return gulp.src('app/*.html')
.pipe(useref())
.pipe(gulpif('*.js', uglify()))
.pipe(gulpif('*.css', minifyCss()))
.pipe(gulp.dest('dist'));
});
示例4: typescriptTask
export function typescriptTask(enableSourcemaps: boolean = false) {
let files = [`${DIR_SRC}/**/*.ts`, 'typings/browser/**/*.d.ts'];
return gulp.src(files, {base: DIR_SRC})
.pipe(gulpif(enableSourcemaps, sourcemaps.init()))
.pipe(typescript(project))
.pipe(gulpif(enableSourcemaps, sourcemaps.write()))
.pipe(gulp.dest(DIR_TMP));
}
示例5: createIndexHTML
task('demos.copySource', (done: Function) => {
const stream = src([`${DEMOS_SRC_ROOT}/**/*`])
.pipe(gulpif(/app.module.ts$/, createIndexHTML()))
.pipe(dest(DIST_DEMOS_ROOT));
stream.on('end', done);
function createIndexHTML() {
const indexTemplate = readFileSync(`${SCRIPTS_ROOT}/${DEMOS_NAME}/demos.template.prod.html`);
const indexTs = readFileSync(`${SCRIPTS_ROOT}/${DEMOS_NAME}/main.ts`);
return obj(function (file, enc, next) {
this.push(new VinylFile({
base: file.base,
contents: new Buffer(indexTemplate),
path: join(dirname(file.path), 'index.html'),
}));
this.push(new VinylFile({
base: file.base,
contents: new Buffer(indexTs),
path: join(dirname(file.path), 'main.ts'),
}));
next(null, file);
});
}
});
示例6: join
export = () => {
let debug: boolean = argv.debug;
let dir=join(Config.TMP_DIR, 'jslocal');
let serviceWorkerFiles = join(dir, '**/service-worker*.js');
let normalFiles=[join(dir, '**/*.js'),
'!' + serviceWorkerFiles];
if (debug) {
console.log('copy.js.local - normal files: ', normalFiles);
console.log('copy.js.local - service worker files: ', serviceWorkerFiles);
}
gulp.src(normalFiles)
.pipe(gulpif(debug, gulpdebug({title:'copy.js.local normal files'})))
.pipe(gulp.dest(Config.JS_DEST));
gulp.src(serviceWorkerFiles)
.pipe(gulpif(debug, gulpdebug({title:'copy.js.local service worker files'})))
.pipe(gulp.dest(Config.PROD_DEST));
};
示例7: buildTypeScript
function buildTypeScript() {
typescriptCompiler = ts.createProject('tsconfig.json', {
typescript: require('typescript')
});
let src = gulp.src(project.transpiler.source).pipe(changedInPlace({ firstPass: true }));
return eventStream
.merge(src)
.pipe(plumber({ errorHandler: notify.onError('Error: <%= error.message %>') }))
.pipe(typescriptCompiler())
.pipe(gulpif(isJsFile, build.bundle()));
}
示例8: getOptimizeStreams
export function getOptimizeStreams(options?: OptimizeOptions):
NodeJS.ReadWriteStream[] {
options = options || {};
const streams = [];
streams.push(gulpif(matchesExt('.js'), new JsTransform(options)));
streams.push(gulpif(matchesExt('.html'), new HtmlTransform(options)));
if (options.css && options.css.minify) {
streams.push(gulpif(
matchesExtAndNotExcluded('.css', options.css.minify),
new CSSMinifyTransform({stripWhitespace: true})));
// TODO(fks): Remove this InlineCSSOptimizeTransform stream once CSS
// is properly being isolated by splitHtml() & rejoinHtml().
streams.push(gulpif(
matchesExtAndNotExcluded('.html', options.css.minify),
new InlineCSSOptimizeTransform({stripWhitespace: true})));
}
return streams;
}
示例9: flatten
return new Promise<void>((resolve, reject) => {
let destinationOptions: vfs.DestOptions;
if (options && options.mode)
destinationOptions = { mode: options.mode };
gulp
.src(sourcePatterns, options)
.pipe(gulpif(options && options.flatten, flatten()))
.pipe(gulp.dest(destination, destinationOptions))
.on("end", resolve)
.on("error", reject);
});
示例10: optimize
export function optimize(options?: OptimizeOptions) {
let transforms = [];
if (options) {
if (options.js && options.js.minify) {
transforms.push(new UglifyTransform());
}
if (options.css && options.css.stripWhitespace) {
transforms.push(cssSlam());
}
if (options.html) {
transforms.push(gulpif(/\.html$/, htmlmin(options.html)));
}
}
return compose(transforms);
}