A plugin for Gulp. Inject css file into html style tags.
npm install gulp-style-inject> style-inject plugin for gulp
First, install gulp-style-inject as a development dependency:
``shell`
npm install --save-dev gulp-style-inject
Then, add it to your gulpfile.js:
`javascript
var styleInject = require("gulp-style-inject");
gulp.src("./src/*.html")
.pipe(styleInject())
.pipe(gulp.dest("./dist"));
`
All your html files should include the following tag:
`html`
Example: Some text Some text
`html`
Some other text`
Outputhtml`
Some other text
The plugin can be used with an options object
`javascript
var styleInject = require("gulp-style-inject");
gulp.src("./src/*.html")
.pipe(styleInject({
encapsulated: false,
path: './test/styles'
}))
.pipe(gulp.dest("./dist"));
``
Available options:
- encapsulated: Type boolean, (default: true) - Specifies if the style code should be injected using a style tag
- path: Type string, (default: '') - Specifies the base path of all style files
- match_pattern: Type regular expression, (default: <\\!--\\sinject-style\\s(.?)\\s-->) - Specifies the pattern to look for when replacing
[npm-url]: https://npmjs.org/package/gulp-style-inject
[npm-image]: https://badge.fury.io/js/gulp-style-inject.png
[travis-url]: http://travis-ci.org/vladfilipro/gulp-style-inject
[travis-image]: https://secure.travis-ci.org/vladfilipro/gulp-style-inject.png?branch=master
[coveralls-url]: https://coveralls.io/r/vladfilipro/gulp-style-inject
[coveralls-image]: https://coveralls.io/repos/vladfilipro/gulp-style-inject/badge.png
[depstat-url]: https://david-dm.org/vladfilipro/gulp-style-inject
[depstat-image]: https://david-dm.org/vladfilipro/gulp-style-inject.png