Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
assetPaths: [
path.resolve(__dirname, '../../../', cwd, 'images'),
path.resolve(__dirname, '../../../', 'packages/core/images')
],
strict: true
})
);
}
return gulp
.src(`${cwd}src/**/*.scss`)
.pipe(
changed(dest, {
extension: '.css',
// compare contents so files that import the updated file also get piped through
hasChanged: changed.compareSha1Digest
})
)
.pipe(gulpIf(createSourcemaps, sourcemaps.init()))
.pipe(sassCompiler)
.pipe(gulpIf(createSourcemaps, sourcemaps.write()))
.pipe(postcss(postcssPlugins))
.pipe(gulp.dest(dest))
.pipe(count(`## Sass files processed in ${cwd}`))
.pipe(shared.browserSync.stream({ match: '**/public/styles/*.css' })); // Auto-inject into docs
}
runOne(done, cwd, watching) {
// setup a run with a single cwd a.k.a base directory FIXME: perhaps this could be in the base recipe? or not?
let options = extend(true, {}, this.config.source.options)
options.cwd = cwd
this.debug(`src: ${cwd}/${this.config.source.glob}`)
return this.gulp.src(this.config.source.glob, options)
.pipe(changed(this.config.dest)) // ignore unchanged files
.pipe(gulpif(this.config.debug, debug(this.debugOptions())))
.pipe(imagemin(this.config.options))
.on('error', (error) => {
this.notifyError(error, done, watching)
})
.pipe(this.gulp.dest(this.config.dest))
.pipe(this.browserSync.stream())
}
}
export function favicons() {
const paths = getPaths('favicons')
return gulp
.src(paths.src)
.pipe(changed(paths.dest)) // Ignore unchanged files
.pipe(gulp.dest(paths.dest))
.pipe(browserSync.stream())
}
gulp.task('fonts', () => {
return gulp.src(config.src)
.pipe(changed(config.dest)) // Ignore unchanged files
.pipe(gulp.dest(config.dest))
.pipe(browserSync.reload({stream: true}));
});
gulp.task("config", () => {
const dest = "build/config";
// In effect, anything in localConfigPath overrides the same file in
// config.
const configPath = "config";
const localConfigPath = "local_config";
return gulp.src(path.join(configPath, "**"), { nodir: true })
.pipe(es.map((file, callback) =>
vinylFile.read(
path.join(localConfigPath, file.relative),
{ base: localConfigPath })
.then(override => callback(null, override),
() => callback(null, file))))
// We do not use newer here as it would sometimes have
// unexpected effects.
.pipe(changed(dest, { hasChanged: changed.compareContents }))
.pipe(gulp.dest(dest));
});
const pathsCopy = [
// Copy all files
`${config.paths.src}/**/*.*`,
// Skip templates
`!${config.paths.src}/templates`,
`!${config.paths.src}/templates/**`,
// Skip assets
`!${config.paths.src}/assets`,
`!${config.paths.src}/assets/**`
];
const options = {
hasChanged: changed.compareContents
};
return () => stream.merge(
gulp.src(pathsCopy, { dot: true })
.pipe(changed(config.paths.build, options))
.pipe(gulp.dest(config.paths.build))
.pipe(preservetime()),
gulp.src(`${config.paths.srcAssets}/**`, { dot: true })
.pipe(changed(config.paths.build, options))
.pipe(gulp.dest(config.paths.buildAssets))
.pipe(preservetime())
);
};
export function buildJs () {
return gulp.src(jsSrc)
.pipe(changed(distDir))
.pipe(sourcemaps.init())
.pipe(babel({modules}).on('error', logError))
.pipe(concat('all.min.js'))
.pipe(uglify().on('error', logError))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(distDir))
}
gulp.task('build:babel', () => gulp.src(`${SRC_DIR}/**/*.js`)
.pipe(changed(BUILD_DIR, { extension: '.js' }))
.pipe(debug({ title: 'Running babel' }))
.pipe(sourcemaps.init())
.pipe(babel(BABELRC_CONTENTS))
.pipe(sourcemaps.write())
.pipe(gulp.dest(BUILD_DIR)));
function compileJs(src, dest, filename) {
return gulp.src(src)
.pipe(concat(filename))
.pipe(wrap("(function (window, document, JSON) { <%= contents %> })(window, document, JSON);"))
.pipe(gulpUglify({}, uglifyJs).on('error', (err) => console.log(err)))
.pipe(changed(jsDest, {
hasChanged: changed.compareSha1Digest
}))
.pipe(gulp.dest(dest));
}