Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
gulp.task('style-sass', function() {
// gulp.src('style/sass/index.scss')
// .pipe(plugins.sass())
// .pipe(plugins.autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
// .pipe(plugins.rename({
// suffix: '.min'
// }))
// .pipe(plugins.minifyCss())
// .pipe(gulp.dest('style/css'))
// .pipe(notify({
// message: 'Styles task complete'
// }));
var combined = combiner.obj([
gulp.src('style/sass/index.scss'),
plugins.sass(),
plugins.rename({
suffix: '.min'
}),
plugins.minifyCss(),
gulp.dest('style/css')
]);
// 任何在上面的 stream 中发生的错误,都不会抛出,
// 而是会被监听器捕获
combined.on('error', console.error.bind(console));
return combined;
});
gulp.watch('src/**/*.js', function (event) {
var paths = watchPath(event,'src/', 'dist/');
/*
paths {srcPath: 'src/file.js',
srcDir: 'src/',
distPath: 'dist/file.node',
distDir: 'dist/',
srcFilename: 'file.js',
distFilename: 'file.js' }
*/
var combined = combiner.obj([
gulp.src(paths.srcPath), // src/file.js
uglify(),
gulp.dest(paths.distDir) // dist/
]);
combined.on('error', function (err) {
console.log('--------------')
console.log('Error')
console.log('fileName: ' + err.fileName)
console.log('lineNumber: ' + err.lineNumber)
console.log('message: ' + err.message)
console.log('plugin: ' + err.plugin)
})
console.log('\n')
console.log(event.type + ': ' + paths.srcPath)
console.log('dist: ' + paths.distPath)
// copy
gulp.src(pathToEs5)
.pipe(gulp.dest(destinations.es5)),
/* This task doesn't work for some reason, deriving from possibly not being able to
find the files, which doesn't make sense since the task above it works just fine. */
// // minify
// gulp.src(pathToEs5)
// .pipe(uglify())
// .pipe(rename({
// suffix: '.min'
// }))
// .pipe(gulp.dest(outputDist_es5))
]);
combine.on('error', console.error.bind(console));
}
function copyToDist() {
combine.obj([
// ts
// copy
tsTranspileSystem(),
// minify System
gulp.src(pathToTs)
.pipe(tsc(tsconfig_system))
.pipe(uglify())
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest(destinations.system)),
tsTranspileCommonJs(),
// minify commonjs
function createUploadPackParser(opts): WritableStream {
return combine.obj(
// Parse as lines
createPackLineParser(),
// Parse metatdata of lines
createPackLineMetaParser(),
// Filter packs
es.map((line, callback) => {
if (line.type == LINEMETA_TYPES.PACKFILE) {
callback(null, line);
} else {
callback();
}
}),
// Parse pack as objects
parsePack(opts)
);
}
gulp.task('html', function(done){
combiner.obj([
gulp.src(config.paths.html)
.pipe(gulp.dest(config.paths.dist))
.pipe(connect.reload())
])
.on('error', console.error.bind(console));
done();
});
gulp.task('styles', () =>
combine(
gulp.src(paths.src.styles.entry),
$.if(IS_DEVELOPMENT, $.sourcemaps.init()),
$.sass(),
$.if(IS_DEVELOPMENT, $.sourcemaps.write()),
$.if(IS_DEVELOPMENT, gulp.dest(paths.root.src)),
$.if(!IS_DEVELOPMENT, gulp.dest(paths.root.dist)),
).on('error', $.notify.onError()),
);
function done () {
var middle = combine.apply(null, streams);
middle.on('error', function (err) {
err.message += ' while parsing file: ' + file;
if (!err.filename) err.filename = file;
dup.emit('error', err);
});
input.pipe(middle).pipe(output);
}
function done () {
var middle = combine.apply(null, streams);
middle.on('error', function (err) {
err.message += ' while parsing file: ' + file;
if (!err.filename) err.filename = file;
dup.emit('error', err);
});
input.pipe(middle).pipe(output);
}
function done () {
var middle = combine.apply(null, streams);
middle.on('error', function (err) {
err.message += ' while parsing file: ' + file;
if (!err.filename) err.filename = file;
self.emit('error', err);
});
input.pipe(middle).pipe(output);
}