Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
error(e, message) {
notify.onError({
title: this.title,
message: message + ': <%= error.message %>',
icon: __dirname + '/../icons/fail.png',
onLast: true
})(e);
// We'll spit out the error, just in
// case it is useful for the user.
console.log(e);
}
export default function processMarkup() {
return gulp.src(project.markupProcessor.source)
.pipe(plumber({errorHandler: notify.onError('Error: <%= error.message %>')}))
.pipe(changedInPlace({firstPass:true}))
.pipe(htmlmin({
removeComments: true,
collapseWhitespace: true,
minifyCSS: true,
minifyJS: true,
ignoreCustomFragments: [/\${.*?}/g] // ignore interpolation expressions
}))
.pipe(build.bundle());
}
gulp.task('build-amd', function() {
return gulp.src(paths.source)
.pipe(plumber({errorHandler: notify.onError('Error: <%= error.message %>')}))
.pipe(changed(paths.output, {extension: '.js'}))
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(to5(assign({}, compilerOptions, {modules: 'amd'})))
.pipe(sourcemaps.write({includeContent: true}))
.pipe(gulp.dest(paths.output));
});
}));
}
var moreIncludePaths = config.sass && config.sass.includePaths;
if (moreIncludePaths instanceof Array) {
includePaths = includePaths.concat(moreIncludePaths);
}
return gulp.src(paths.makeFullPath(config.assets.styles.src, paths.SRC))
.pipe(isRelease ? gutil.noop() : sourcemaps.init())
.pipe(sass({
includePaths: includePaths,
outputStyle: (isRelease ? "compressed" : "nested")
}))
.on("error", function (error) {
this.emit("end");
})
.on("error", notify.onError(function (error) {
return "SASS: " + error.message;
}))
.pipe(autoprefixer({browsers: ["last 2 versions"]}))
.pipe(isRelease ? gutil.noop() : sourcemaps.write())
.pipe(gulp.dest(paths.makeFullPath(config.assets.styles.dest, paths.DEST)))
.pipe(browserSync.stream());
}
module.exports = function(error) {
notify.onError(error.toString()).apply(this, arguments);
gutil.log(error.stack);
this.emit('end');
};
function rebundle() {
let stream = bundler.bundle();
return stream
.on("error", notify.onError({
message: "Error: <%= error.message %>",
title: "Error building scripts"
}))
.on('end', function() { gutil.log("Done building scripts"); })
.pipe(source(entryFile))
.pipe(rename('index.js'))
.pipe(gulp.dest(path.join(dist, 'scripts')));
};
tasks.templates = function assetsTemplates() {
let sources = [path.join(settings.BASE_DIR, './components/**/*.vue')]
return gulp.src(sources)
.pipe(vueCompiler({
commonjs: false,
namespace: 'global.templates',
pathfilter: ['src', 'components', 'node_modules'],
}))
.on('error', notify.onError('Error: <%= error.message %>'))
.pipe(ifElse(settings.BUILD_OPTIMIZED, () => minifier()))
.pipe(concat('templates.js'))
.pipe(insert.prepend('global.templates={};'))
.pipe(gulp.dest(path.join(settings.BUILD_DIR, 'js')))
.pipe(size(_extend({title: 'templates'}, settings.SIZE_OPTIONS)))
}
const gulp = require('gulp');
const plumber = require('gulp-plumber');
const notify = require('gulp-notify');
const gulpif = require('gulp-if');
const browserSync = require('browser-sync');
const lessPipe = require('../pipe/less');
const util = require('gulp-util');
const config = util.env.boilerplate.config;
const lessConfig = config.tasks[configName];
const isWatching = ['serve', 'watch'].indexOf(process.argv[2]) >= 0;
return gulp.src(lessConfig.source, {cwd: config.sourceRoot})
.pipe(plumber({
errorHandler: notify.onError({
message: '<%= error.message %>',
title: 'Less Error'
})
}))
.pipe(lessPipe())
.pipe(gulp.dest(config.destinationRoot + lessConfig.destination))
.pipe(gulpif(isWatching, browserSync.stream({once: true})))
.pipe(notify('Successfully compiled Less ' + configName));
};
const maybeNotifyErrors = () => notify.onError({
title: 'Compile Error',
message: '<%= error.message %>',
});
module.exports = () => {
return src([config.paths.source.template + config.paths.assets.scss], {
sourcemaps: true,
base: config.paths.source.template
})
.pipe(plumber({
errorHandler: notify.onError('Error: <%= error.message %>')
}))
.pipe(sass())
.pipe(postcss([
autoprefixer(),
cssmqpacker({
sort: sortCSSmq
}),
]))
.pipe(cleanCSS())
.pipe(rename((path) => {
path.dirname = path.dirname.replace(/scss$/, 'css')
if (path.extname === '.css') path.extname = '.min.css'
}))
.pipe(dest(config.paths.output.template, {sourcemaps: '.'}))
}