Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 3 days 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 (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-05-09T03:06:20.000Z (over 7 years ago)
- Last Synced: 2024-12-18T04:47:29.704Z (about 1 month 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
[![Build Status](https://travis-ci.org/KamataRyo/gulp-css2txt.svg?branch=master)](https://travis-ci.org/KamataRyo/gulp-css2txt)
[![npm version](https://badge.fury.io/js/gulp-css2txt.svg)](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())
})
```