Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function buildJavaScript() {
let transpile = babel(project.transpiler.options);
if (useCache) {
// the cache directory is "gulp-cache/projName-env" inside folder require('os').tmpdir()
// use command 'au clear-cache' to purge all caches
transpile = cache(transpile, {name: project.name + '-' + env});
}
return gulp.src(project.transpiler.source, {sourcemaps: true, since: gulp.lastRun(buildJavaScript)})
.pipe(plumber({errorHandler: notify.onError('Error: <%= error.message %>')}))
.pipe(transpile)
.pipe(build.bundle());
}
gulp.task('less', () => {
return gulp.src([ src_assets_folder + 'less/**/!(_)*.less'], { since: gulp.lastRun('less') })
.pipe(sourcemaps.init())
.pipe(plumber())
.pipe(less())
.pipe(autoprefixer())
.pipe(minifyCss())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(dist_assets_folder + 'css'))
.pipe(browserSync.stream());
});
async function compile() {
return src('build/js/**/*.js', {
since: lastRun(compile)
})
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(envify(env))
.pipe(unassert())
.pipe(babel())
.pipe(gulpif(PROD, terser()))
.pipe(gulpif(PROD, rev()))
.pipe(sourcemaps.write('./'))
.pipe(dest(config.buildBase))
.pipe(gulpif(DEV, lr(config.livereload)))
.pipe(gulpif(PROD, rev.manifest(config.manifest, manifestOptions)))
.pipe(gulpif(PROD, dest(config.buildBase)));
}
export default function copyFiles(done) {
if (typeof project.build.copyFiles !== 'object') {
done();
return;
}
const instruction = getNormalizedInstruction();
const files = Object.keys(instruction);
return gulp.src(files, {since: gulp.lastRun(copyFiles)})
.pipe(gulp.dest(x => {
const filePath = prepareFilePath(x.path);
const key = files.find(f => minimatch(filePath, f));
return instruction[key];
}));
}
function typescript_dev_zkmax() {
return typescript_dev(
'../zkcml/zkmax/src/archive',
'../zkcml/zkmax/debug/classes',
gulp.lastRun(typescript_dev_zkmax)
);
}
export default function processJson () {
return gulp
.src(project.jsonProcessor.source, { since: gulp.lastRun(processJson) })
.pipe(build.bundle())
}
task('build:docs:toc', () =>
src(markdownSrc, { since: lastRun('build:docs:toc') }).pipe(
through2.obj((file, enc, done) => {
sh(`doctoc ${file.path} --github --maxlevel 4 && git add ${file.path}`, done)
}),
),
)
gulp.task('fonts', () => gulp.src(['assets/fonts/*', 'node_modules/font-awesome/fonts/*'], { since: gulp.lastRun('fonts') })
.pipe(gulp.dest('build/assets/fonts/')));
const js = () => {
return gulp
.src(jsFiles, { since: gulp.lastRun(js) })
.pipe(eslint())
.pipe(eslint.format())
.pipe(gulp.dest(distPath));
};
gulp.task(js);