gulp


Gulp Minify SVG to a string


I replace the IMG tag with the inline code from the SVG file. How do I minify SVG code before I insert it in the js file?
gulp.task('js', function() {
return gulp.src('./src/js/**/*.js')
.pipe(replace(/<img src="\/img\/icons\/(.*?)">/g, function(match, p1) {
return fs.readFileSync('./src/img/icons/'+p1, 'utf8');
}))
.pipe( jshint() )
.pipe( minify({
ext:{
min:'.min.js'
},
ignoreFiles: ['*.min.js', '*-min.js']
}))
.pipe( gulp.dest('./build/js') )
.pipe(notify({ message: "JS done.", onLast: true }));
});
Found it, replace the line:
return fs.readFileSync('./src/img/icons/'+p1, 'utf8');
with:
return fs.readFileSync('./src/img/icons/'+p1, 'utf8').replace(/\r?\n|\r/g, '');

Related Links

coverage report generation fails: mocha > gulp-mocha > gulp-istanbul
How to customize container width in Semantic UI
Error while running stubby4node using Gulp
Only run a gulp task if two files are different
Deleted vue template, gulp, webpack, babel
vue.js + gulp. How to build in a single js and css file.
Gulp watch don't overwrite files
MinGW bash sudo command not found
Gulp task with prerequisite does not start
gulp image resize, resize to correct location
Sourcemaps for my Gulp Sass task dosen't work
How to pass multiCapabilities from gulp-angular-protractor
Gulp watch error with gulp-pug
gulp-ruby-sass src globbing issue
how to install a package in yeoman project?
Merge files only if they go deeper than two levels

Categories

HOME
google-cloud-pubsub
twitter-bootstrap
swift3
service
readdir
spotfire
assign
squeak
aggregation-framework
rethinkdb
doctrine2
obd-ii
ethereum
jcodemodel
desktop-application
resharper
exchange-transport-agents
jsfiddle
geography
caldav
bootstrap-datetimepicker
handle
jira-zephyr
deployment-descriptor
android-cursorloader
akamai
blockly
ibm-bpm
favorites
n1ql
minitest
azure-vm-scale-set
kofax
console.readline
stdin
mediastream
azure-web-roles
electron-packager
java-5
taiga
codepen
synchronized
react.rb
openxava
skype-bots
appcmd
fluent-nhibernate-mapping
activesupport
sp
r-commander
selection-sort
dmalloc
reloaddata
breadcrumbs
spring-social-twitter
scriptengine
airwatch
objectify
nsoperationqueue
jmh
mod
methodology
fadein
kramdown
skscene
magnet-uri
database-project
uinavigationitem
nmock
vectordrawable
applinks
launcher
novell
iwork
pthreads-win32
boofcv
ekevent
8-puzzle
ie-developer-tools
extensibility
mandelbrot
select2-rails
windows-scheduler
rbm
qt5.1
mail-gem
django-1.4
inserthtml
scsf
lightopenid
cpack
oaw
appointment
wtsapi32
unauthorized

Resources

Encrypt Message