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('build:cjs', () => {
return gulp
.src(srcGlob)
.pipe(plumber())
.pipe(babel()) // config in .babelrc
.pipe(plumber.stop())
.pipe(gulp.dest(distCjsDir))
})
gulp.task('lint:javascript', function () {
// DOCS: http://eslint.org
return gulp.src(PROJECT_PATTERNS.js)
.pipe(gulpif(!process.env.CI, plumber()))
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError())
.pipe(gulpif(!process.env.CI, plumber.stop()));
});
gulp.task('lint:javascript', function() {
// DOCS: http://eslint.org
return gulp
.src(PROJECT_PATTERNS.js)
.pipe(gulpif(!process.env.CI, plumber()))
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError())
.pipe(gulpif(!process.env.CI, plumber.stop()));
});
gulp.task('compile', function() {
return gulp
.src('src/**/*.js')
.pipe(plumber({
errorHandler: function(err) {
console.error(err.stack);
this.emit('end');
}
}))
.pipe(sourcemaps.init())
.pipe(babel(options))
.pipe(plumber.stop())
.pipe(sourcemaps.write('maps/'))
.pipe(gulp.dest('dist/'));
});
gulp.task('sass', function () {
return gulp.src('scss/**/*.scss')
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(sass({errLogToConsole: true}))
.pipe(sourcemaps.write('./'))
.pipe(plumber.stop())
.pipe(gulp.dest('./dist/css'))
.pipe(reload({stream:true}));
});
gulp.task('css:sass', function() {
gulp.src(paths.src.scss)
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(sass())
.pipe(sourcemaps.write())
.pipe(plumber.stop())
.pipe(gulp.dest(paths.dest.css))
.pipe(connect.reload());
});
function buildJS ( src, destFile ) {
return gulp.src( src )
.pipe( plumber( {
errorHandler: notify.onError( function ( error ) {
return error.name + ': ' + error.message + '\n' + error.cause.filename + '[' + error.cause.line + ':' + error.cause.col + '] ' + error.cause.message;
} )
} ) )
.pipe( sourcemaps.init() )
.pipe( uglify() )
.pipe( plumber.stop() )
.pipe( concat( destFile ) )
.pipe( sourcemaps.write( 'maps' ) )
.pipe( gulp.dest( './build/' ) )
.pipe( notify( {
title: 'Gulp',
message: 'Built: ' + destFile,
onLast: true
} ) );
}
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(less())
.pipe(autoprefixer())
.pipe(minify({
minify: true,
collapseWhitespace: true,
conservativeCollapse: true,
minifyCSS: true,
getKeptComment: function (content, filePath) {
var m = content.match(/\/\*![\s\S]*?\*\//img);
return m && m.join('\n') + '\n' || '';
}
}))
.pipe(sourcemaps.write('../maps'))
.pipe(plumber.stop())
.pipe(gulp.dest('statics/css'));
}
debug: config.js.sourcemaps.debug
})))
.pipe(order(bootstrap, {base: './'}))
.pipe(concat('bootstrap.js'))
.pipe(gulpif(config.js.sourcemaps.generate == true, sourcemaps.write(config.js.sourcemaps.location, {
addComment: config.js.sourcemaps.addcomment,
includeContent: config.js.sourcemaps.includeContent,
sourceRoot: function (file) {
return '../'.repeat(file.relative.split('\\').length) + 'src';
},
destPath: config.js.sourcemaps.destpath,
sourceMappingURLPrefix: config.js.sourcemaps.sourcemappingurlprefix,
debug: config.js.sourcemaps.debug,
charset: config.js.sourcemaps.charset
})))
.pipe(plumber.stop())
.pipe(gulp.dest(config.locations.javascript.libraries))
.pipe(gulpif(config.js.minify === true, uglify()))
.pipe(gulpif(config.js.minify === true, rename(function (path) {
path.basename += '.min';
})))
.pipe(gulpif(config.js.minify === true, gulp.dest(config.locations.javascript.libraries)))
.pipe(gulpif(config.js.gzip === true, gzip()))
.pipe(gulpif(config.js.gzip === true, gulp.dest(config.locations.javascript.libraries)));
}
function _js() {
gulp.src('source/js/*.js')
.pipe(debug({ title: 'js:' }))
.pipe(plumber())
.pipe(babel({
presets: ['es2015']
}))
.pipe(concat('main.js'))
.pipe(plumber.stop())
.pipe(gulp.dest('statics/js'));
}