本文整理汇总了TypeScript中merge-stream类的典型用法代码示例。如果您正苦于以下问题:TypeScript merge-stream类的具体用法?TypeScript merge-stream怎么用?TypeScript merge-stream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了merge-stream类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
return function() {
// https://www.npmjs.com/package/merge-stream
return merge(copyProjectInternalAsets(), copyProjectExternalAsets());
// copies all external asset dependencies (d.asset === true)
// to their designated destionations (d.dest)
function copyProjectExternalAsets() {
var externalAssetFiles = DEV_DEPENDENCIES.filter(d => d.asset);
// http://stackoverflow.com/questions/26784094/can-i-use-a-gulp-task-with-multiple-sources-and-multiple-destinations
var tasks = externalAssetFiles.map(function(element) {
// https://github.com/gulpjs/gulp/blob/master/docs/API.md#gulpsrcglobs-options
return gulp.src(element.src)
// https://github.com/gulpjs/gulp/blob/master/docs/API.md#gulpdestpath-options
.pipe(gulp.dest(element.dest));
});
return merge(...tasks);
}
// copies set of asset files (not *.ts) from APP_SRC to APP_DEST
// it will copy js files, css, html files,
function copyProjectInternalAsets() {
return gulp.src([
join(APP_SRC, '**'),
'!' + join(APP_SRC, '**', '*.ts')
])
.pipe(gulp.dest(APP_DEST));
}
};
示例2: function
return function () {
let debug = false;
// https://www.npmjs.com/package/merge-stream
return merge(minifyComponentCss(), prepareTemplates(), processExternalCss());
// copies html templates to tmp dir
function prepareTemplates() {
return gulp.src(join(APP_SRC, '**', '*.html'))
.pipe(gulp.dest(TMP_DIR));
}
// minify css files from the project
// TODO: mprinc:
// - not sure why not minifying assets?
// - probable because assets are something that we are not working on,
// but just providing to the project output
// still it would make sense to minify them or at least concat them together
function minifyComponentCss() {
return gulp.src([
join(APP_SRC, '**', '*.css'),
'!' + join(APP_SRC, 'assets', '**', '*.css')
])
// https://www.npmjs.com/package/gulp-cssnano
.pipe(plugins.cssnano())
.pipe(gulp.dest(TMP_DIR));
}
// gets external css from PROD_DEPENDENCIES (config.ts file)
// minifies them into CSS_PROD_BUNDLE and stores in CSS_DEST (config.ts file)
function processExternalCss() {
var externalCssFiles = getExternalCss().map(r => r.src);
if(debug) plugins.util.log('[processExternalCss] externalCssFiles: ', externalCssFiles);
// if(debug) plugins.util.log('[processExternalCss] CSS_PROD_BUNDLE: ', CSS_PROD_BUNDLE);
// if(debug) plugins.util.log('[processExternalCss] CSS_DEST: ', CSS_DEST);
let stream = gulp.src(externalCssFiles)
.pipe(plugins.sniff('processExternalCss', {detailed: true}))
.pipe(plugins.cssnano())
.pipe(plugins.concat(CSS_PROD_BUNDLE))
.pipe(gulp.dest(CSS_DEST));
stream.on('end', function() {
if(debug) plugins.util.log(plugins.util.colors.blue("[build.js.prod:processExternalCss]"),
plugins.sniff.get("processExternalCss"));
});
return stream;
}
// get css files from external dependencies listed in
// config.ts file under PROD_DEPENDENCIES
function getExternalCss() {
var externalCssFiles = PROD_DEPENDENCIES.filter(d => /\.css$/.test(d.src));
// if(debug) plugins.util.log('[getExternalCss] externalCssFiles: ', externalCssFiles);
return externalCssFiles;
}
};
示例3: function
return function () {
return merge(bundleShims());
// get sources of *.js dependencies that .inject are either shims or libs or true
function getShims() {
let libs = PROD_DEPENDENCIES
.filter(d => /\.js$/.test(d.src));
return libs.filter(l => l.inject === 'shims')
.concat(libs.filter(l => l.inject === 'libs'))
.concat(libs.filter(l => l.inject === true))
.map(l => l.src);
}
function bundleShims() {
return gulp.src(getShims())
// Minify files with UglifyJS
// https://www.npmjs.com/package/gulp-uglify
// Strip comments and sourcemaps
.pipe(plugins.uglify({
mangle: false
}))
.pipe(plugins.concat(JS_PROD_SHIMS_BUNDLE))
.pipe(gulp.dest(JS_DEST));
}
};
示例4: function
return function () {
return merge(bundleShims(), bundleApp());
function getShims() {
let libs = PROD_DEPENDENCIES
.filter(d => /\.js$/.test(d.src));
return libs.filter(l => l.inject === 'shims')
.concat(libs.filter(l => l.inject === 'libs'))
.concat(libs.filter(l => l.inject === true))
.map(l => l.src);
}
function bundleShims() {
return gulp.src(getShims())
// Strip comments and sourcemaps
.pipe(plugins.uglify({
mangle: false
}))
.pipe(plugins.concat(JS_PROD_SHIMS_BUNDLE))
.pipe(gulp.dest(JS_DEST));
}
function bundleApp() {
return browserify(join(TMP_DIR, 'main'))
.bundle()
.pipe(require('vinyl-source-stream')(JS_PROD_APP_BUNDLE))
.pipe(require('vinyl-buffer')())
.pipe(plugins.uglify({
mangle: false
}))
.pipe(gulp.dest(JS_DEST));
}
};
示例5: function
return function () {
return merge(buildSass(), minifyComponentCss(), prepareTemplates(), processExternalCss());
function prepareTemplates() {
return gulp.src(join(TMP_SRC, '**', '*.html'))
.pipe(gulp.dest(TMP_DIR));
}
function buildSass() {
return gulp.src(join(TMP_SRC, '**', '*.scss'))
.pipe(plugins.sass().on('error', plugins.sass.logError))
.pipe(gulp.dest(TMP_SRC));
}
function minifyComponentCss() {
return gulp.src([
join(TMP_SRC, '**', '*.css'),
'!' + join(TMP_SRC, 'assets', '**', '*.css')
])
.pipe(plugins.cssnano())
.pipe(gulp.dest(TMP_DIR));
}
function processExternalCss() {
return gulp.src(getExternalCss().map(r => r.src))
.pipe(plugins.cssnano())
.pipe(plugins.concat(CSS_PROD_BUNDLE))
.pipe(gulp.dest(CSS_DEST));
}
function getExternalCss() {
return PROD_DEPENDENCIES.filter(d => /\.css$/.test(d.src));
}
};
示例6: function
return function () {
return merge(minifyComponentCss(), prepareTemplates(), processExternalCss());
function prepareTemplates() {
return gulp.src(join(APP_SRC, "**", "*.html"))
.pipe(gulp.dest(TMP_DIR));
}
function minifyComponentCss() {
return gulp.src([
join(APP_SRC, "**", "*.css"),
"!" + join(APP_SRC, "assets", "**", "*.css")
])
.pipe(plugins.cssnano())
.pipe(gulp.dest(TMP_DIR));
}
function processExternalCss() {
return gulp.src(getExternalCss().map(r => r.src))
.pipe(plugins.cssnano())
.pipe(plugins.concat(CSS_PROD_BUNDLE))
.pipe(gulp.dest(CSS_DEST));
}
function getExternalCss() {
return PROD_DEPENDENCIES.filter(d => /\.css$/.test(d.src));
}
};
示例7: function
return function() {
return merge(buildComponentCss(), processExternalCss());
function buildComponentCss() {
return gulp.src([
join(APP_SRC, '**', '*.scss'),
'!' + join(APP_SRC, 'assets', '**', '*.css')
])
.pipe(plugins.sass({ errLogToConsole: false }))
.pipe(plugins.autoprefixer({ browsers: ['last 2 version'] }))
.pipe(plugins.cssnano())
.pipe(gulp.dest(TMP_DIR));
}
function processExternalCss() {
return gulp.src(getExternalCss().map(r => r.src))
.pipe(plugins.cssnano())
.pipe(plugins.concat(CSS_PROD_BUNDLE))
.pipe(gulp.dest(CSS_DEST));
}
function getExternalCss() {
return PROD_DEPENDENCIES.filter(d => /\.css$/.test(d.src));
}
};
示例8: function
return function () {
return merge(bundleShims());
function getShims() {
let libs = PROD_DEPENDENCIES
.filter(d => /\.js$/.test(d.src));
return libs.filter(l => l.inject === 'shims')
.concat(libs.filter(l => l.inject === 'libs'))
.concat(libs.filter(l => l.inject === true))
.map(l => l.src);
}
// This takes, PROD_DEPENDENCIES from config, and looks for JS,SHIMS,Libs files in specified path
// adds them to a common JS bundle (Shimps.js) and saves them to a JS_DEST.
function bundleShims() {
return gulp.src(getShims())
// Strip comments and sourcemaps
.pipe(debug({title:'build.bundle.getShims.src'}))
.pipe(plugins.uglify({
mangle: false
}))
.pipe(debug({title:'build.bundle.getShims.uglify'}))
.pipe(plugins.concat(JS_PROD_SHIMS_BUNDLE))
.pipe(debug({title:'build.bundle.JS_PROD_SHIMS_BUNDLE.concat'}))
.pipe(gulp.dest(JS_DEST))
.pipe(debug({title:'build.bundle.JS_DEST.concat'}));
}
};
示例9: merge
run() {
return merge(
copyAssets(),
copyAppResources(),
copyAppFonts(),
copyFiles([join(Config.TNS_APP_SRC, 'package.json')], ''),
);
}
示例10: copyProjectExternalAsets
// copies all external asset dependencies (d.asset === true)
// to their designated destionations (d.dest)
function copyProjectExternalAsets() {
var externalAssetFiles = PROD_DEPENDENCIES.filter(d => d.asset);
// http://stackoverflow.com/questions/26784094/can-i-use-a-gulp-task-with-multiple-sources-and-multiple-destinations
var tasks = externalAssetFiles.map(function(element){
// https://github.com/gulpjs/gulp/blob/master/docs/API.md#gulpsrcglobs-options
return gulp.src(element.src)
// https://github.com/gulpjs/gulp/blob/master/docs/API.md#gulpdestpath-options
.pipe(gulp.dest(element.dest));
});
return merge(...tasks);
}