gulp-style-inject
A plugin for Gulp. Inject css file into html style tags.
Last updated a month ago by vladfilipro .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install gulp-style-inject 
SYNC missed versions from official npm registry.

gulp-style-inject

NPM version Build Status Coverage Status Dependency Status

style-inject plugin for gulp

Usage

First, install gulp-style-inject as a development dependency:

npm install --save-dev gulp-style-inject

Then, add it to your gulpfile.js:

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:

    <!-- inject-style src="./path/file.css" -->

Example:

<div>
<!-- inject-style src="./test/p.css" -->
<!-- inject-style src="./test/span.css" -->
    <p>Some text</p>
    <span>Some other text</span>
</div>

Output

<div>
<style>
p {
    background-color: red;
}
</style>
<style>
span {
    background-color: green;
}
</style>
    <p>Some text</p>
    <span>Some other text</span>
</div>

Options

The plugin can be used with an options object

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

License

MIT License

Current Tags

  • 0.1.3                                ...           latest (a month ago)

7 Versions

  • 0.1.3                                ...           a month ago
  • 0.1.2                                ...           a year ago
  • 0.1.1                                ...           2 years ago
  • 0.1.0                                ...           4 years ago
  • 0.0.3                                ...           5 years ago
  • 0.0.2                                ...           5 years ago
  • 0.0.1                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 25
Dependencies (3)
Dev Dependencies (6)

Copyright 2014 - 2017 © taobao.org |