https://github.com/kamataryo/gulp-css2txt
gulp-css2txt is a gulp plugin to extract possible characters from css which may be appear in browser
https://github.com/kamataryo/gulp-css2txt
Last synced: 4 months ago
JSON representation
gulp-css2txt is a gulp plugin to extract possible characters from css which may be appear in browser
- Host: GitHub
- URL: https://github.com/kamataryo/gulp-css2txt
- Owner: kamataryo
- License: mit
- Created: 2017-03-31T15:03:05.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-05-09T03:06:20.000Z (about 8 years ago)
- Last Synced: 2025-02-19T02:21:20.521Z (5 months ago)
- Language: JavaScript
- Homepage:
- Size: 43 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gulp-css2txt
[](https://travis-ci.org/KamataRyo/gulp-css2txt)
[](https://badge.fury.io/js/gulp-css2txt)
gulp-css2txt is a gulp plugin to extract possible characters from css which may be appear in browser.
## install
```shell
$ npm install -D gulp-css2txt
```## Simple usage
### Static import
```javascript
import gulp from 'gulp'
import css2txt from 'gulp-css2txt'gulp.task('css2txt', () => {
gulp.src(['path/to/the.css'])
.pipe(css2txt())
.pipe(gulp.dest('dist/'))
})
```### CommonJS style
```javascript
const gulp = require('gulp')
const css2txt = require('gulp-css2txt')gulp.task('css2txt', () => {
gulp.src(['path/to/the.css'])
.pipe(css2txt({ opts }))
.pipe(gulp.dest('dist/'))
})
```## Overview of transformation
### input
CSS is acceptable input.
```css
.foo::before {
content: 'abc'
}
.bar::before {
content: "def"
}
.baz::after {
content: '\47'; /* G */
}
```### output
Output willbe aggregated characters.
```text
abcdefG
```## Example stack of font subsetting with `gulp-fontmin`
### prepare
```shell
$ npm install -D gulp gulp-css2txt gulp-fontmin
$ npm install -S font-awesome
``````javascript
import gulp from 'gulp'
import css2txt from 'gulp-css2txt'
import fontmin from 'gulp-fontmin'gulp.task('font', cb => {
const texts = []
gulp.src(['./dist/*.css'])
.pipe(css2txt())
.on('data', file => texts.push(file.contents.toString()))
.on('end', () => {const text = texts.join('')
const formats = ['eot', 'ttf', 'woff', 'svg']gulp.src('./node_modules/font-awesome/fonts/**/*.ttf')
.pipe(fontmin({ text, formats }))
.pipe(gulp.dest('./dist'))
.on('end', () => cb())
})
```