Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function svgmin (settings) {
return gulp.src('**/*.svg', {
cwd: settings.assets.images
})
.pipe(
gulpSvgmin()
)
.pipe(
gulp.dest(settings.dist.images)
);
}
g.task("svg_minify", () => g.src("asset/**/*.svg").pipe(svgMin()).pipe(g.dest("build/asset/")).pipe(liveReload()))
gulp.task('sprites', () => {
gulp.src(join(src, 'images', '**/*.svg'))
.pipe(svgmin())
.pipe(cheerio({
run($) { $('[fill]').removeAttr('fill'); },
parserOptions: { xmlMode: true },
}))
.pipe(svgstore({ inlineSvg: true }))
.pipe(concat('sprites.ejs'))
.pipe(gulp.dest(join(src, 'html', 'partials')));
});
gulp.task('minify', () =>
gulp.src('icons/*.svg')
.pipe(svgmin({
plugins: [
{
removeTitle: true,
},
{
mergePaths: false,
},
{
convertShapeToPath: false,
},
{
removeAttrs: {
attrs: '(fill|stroke.*)',
},
},
],
gulp.task('spinners', () => {
const optimised = gulp
.src('src/spinners/**/*.svg')
.pipe(chmod(0o644))
.pipe(
svgmin({
plugins: [
...svgoCommonPlugins,
{
removeAttrs: {
attrs: ['id', 'class', 'data-name', 'fill', 'fill-rule'],
},
},
],
}),
)
.pipe(gulp.dest('src/spinners'));
const react = optimised
.pipe(clone())
.pipe(svg2react())
.pipe(rename({ extname: '.js' }))
gulp.task('svgs', () => {
return gulp
.src(`${config.svgs.source}/**/*`)
.pipe(changed(`${config.svgs.build}`))
.pipe(
plumber({errorHandler: notify.onError('Error: <%= error.message %>')})
)
.pipe(
svgmin({
js2svg: {
pretty: true,
},
plugins: [
{
removeDesc: true,
},
{
cleanupIDs: true,
},
{
mergePaths: false,
},
],
})
)
gulp.task('svg', () => gulp
.src(config.globalPaths.src + config.sourcePaths.images + '/*.svg')
.pipe(svgmin({
plugins: [
{
removeTitle: true
},
{
cleanupIDs: false
}
]
}))
.pipe(gulp.dest(config.globalPaths.dist))
);
export function svg() {
gulp.src(paths.svgs.input)
.pipe(plumber())
.pipe(tap((file, t) => {
if (file.isDirectory()) {
let name = file.relative + '.svg'
gulp.src(file.path + '/**/*.svg')
.pipe(svgstore({
fileName: name,
prefix: 'icon-',
inlineSvg: true
}))
.pipe(gulp.dest(paths.svgs.output))
}
}))
.pipe(svgmin())
.pipe(size({'title': 'SVG'}))
.pipe(gulp.dest(paths.svgs.output))
}
process.env.PWD,
PATH_CONFIG.public,
PATH_CONFIG.sprites.dest
)
}
TASK_CONFIG.sprites.mode.css.render.scss.dest = `/_assets/${PATH_CONFIG.scss
.src}/${dest}`
TASK_CONFIG.sprites.mode.css.render.scss.template = path.resolve(
process.env.PWD,
template
)
return gulp
.src(paths.src)
.pipe(svgmin())
.pipe(svgSprite(TASK_CONFIG.sprites))
.pipe(gulp.dest(paths.dest))
.pipe(browserSync.stream())
}
gulp.task('iconfont', () => {
return gulp
.src('anubis/ui/misc/icons/*.svg')
.pipe(svgmin())
.pipe(gulp.dest('anubis/ui/misc/icons'))
.pipe(iconfont({
fontHeight: 1000,
prependUnicode: false,
descent: 6.25 / 100 * 1000,
fontName: 'anubisIcon',
formats: ['svg', 'ttf', 'eot', 'woff', 'woff2'],
timestamp: iconTimestamp,
normalize: true,
}))
.on('glyphs', (glyphs, options) => {
gulp
.src('anubis/ui/misc/icons/template/*.styl')
.pipe(nunjucks.compile({glyphs, options}))
.pipe(gulp.dest('anubis/ui/misc/.iconfont'))
})