Last active
September 2, 2016 07:15
-
-
Save romamaslennikov/a47483f2595f17ec4535464394076866 to your computer and use it in GitHub Desktop.
gulp: serve, iconfont
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@font-face { | |
font-family: '<%= fontName %>'; | |
src: url('<%= fontPath %><%= fontName %>.eot'); | |
src: url('<%= fontPath %><%= fontName %>.eot?#iefix') format('embedded-opentype'), | |
url('<%= fontPath %><%= fontName %>.woff') format('woff'), | |
url('<%= fontPath %><%= fontName %>.ttf') format('truetype'), | |
url('<%= fontPath %><%= fontName %>.svg#<%= fontName %>') format('svg'); | |
font-weight: normal; | |
font-style: normal; | |
} | |
[class*='<%= cssClass %>']:before { | |
font-family: '<%= fontName %>'; | |
display: inline-block; | |
font-style: normal; | |
font-weight: normal; | |
line-height: 1; | |
-webkit-font-smoothing: antialiased; | |
-moz-osx-font-smoothing: grayscale | |
} | |
<% _.each(glyphs, function(glyph) { %>.<%= cssClass %><%= glyph.fileName %>:before {content:'\<%= glyph.codePoint %>';} | |
<% }); %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm up -D |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let iconfont = require('gulp-iconfont'); | |
let iconfontCss = require('gulp-iconfont-css'); | |
let runTimestamp = Math.round(Date.now()/1000); | |
let gulp = require('gulp'); | |
let browserSync = require('browser-sync'); | |
let patch = ''; | |
let fontName = ''; | |
let cssClassPrefix = ''; | |
let paths = { | |
app: ['./'+patch+'/css/**/*.css', | |
'./'+patch+'/js/*.js', | |
'./'+patch+'/*.html'] | |
}; | |
gulp.task('iconfont', () => { | |
gulp.src(['./'+patch+'/icons/*.svg']) | |
.pipe(iconfontCss({ | |
fontName: fontName, | |
cssClass: cssClassPrefix, | |
path: '_icons_template.scss', | |
targetPath: 'icons.css', | |
fontPath: '../fonts/' | |
})) | |
.pipe(iconfont({ | |
fontName: fontName, | |
prependUnicode: true, // recommended option | |
formats: ['ttf', 'eot', 'woff', 'woff2', 'svg'], | |
timestamp: runTimestamp // recommended to get consistent builds when watching files | |
})) | |
.pipe(gulp.dest('./'+patch+'/fonts/')); | |
}); | |
gulp.task('dev', () => { | |
let reload = browserSync.reload; | |
browserSync({ | |
proxy: 'localhost', | |
notify: false, | |
open: false | |
}); | |
gulp.watch(paths.app, () => { | |
return gulp.src(paths.app) | |
.pipe(reload({stream: true})); | |
}); | |
}); | |
gulp.task('default', ['dev']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "yodo", | |
"version": "1.0.0", | |
"description": "", | |
"directories": { | |
"test": "test" | |
}, | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"repository": { | |
"type": "git" | |
}, | |
"author": "", | |
"license": "ISC", | |
"homepage": "", | |
"devDependencies": { | |
"browser-sync": "^2.14.0", | |
"gulp": "^3.9.1", | |
"gulp-iconfont": "^8.0.1", | |
"gulp-iconfont-css": "^2.1.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment