{"id":16690642,"url":"https://github.com/jonkemp/gulp-inline-css","last_synced_at":"2025-10-05T03:30:31.222Z","repository":{"id":13958358,"uuid":"16658637","full_name":"jonkemp/gulp-inline-css","owner":"jonkemp","description":"Inline linked css in an html file. Useful for emails.","archived":false,"fork":false,"pushed_at":"2021-10-19T03:49:30.000Z","size":565,"stargazers_count":272,"open_issues_count":28,"forks_count":29,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-10-19T20:37:33.314Z","etag":null,"topics":["gulp-plugin","inline-css"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonkemp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-02-09T03:03:07.000Z","updated_at":"2024-01-04T08:52:52.000Z","dependencies_parsed_at":"2022-08-24T16:21:55.144Z","dependency_job_id":null,"html_url":"https://github.com/jonkemp/gulp-inline-css","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonkemp%2Fgulp-inline-css","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonkemp%2Fgulp-inline-css/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonkemp%2Fgulp-inline-css/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonkemp%2Fgulp-inline-css/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonkemp","download_url":"https://codeload.github.com/jonkemp/gulp-inline-css/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247157081,"owners_count":20893202,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gulp-plugin","inline-css"],"created_at":"2024-10-12T16:04:37.934Z","updated_at":"2025-10-05T03:30:26.146Z","avatar_url":"https://github.com/jonkemp.png","language":"JavaScript","readme":"# [gulp](https://github.com/wearefractal/gulp)-inline-css ![Build Status](https://github.com/jonkemp/gulp-inline-css/actions/workflows/main.yml/badge.svg?branch=master) [![Coverage Status](https://coveralls.io/repos/jonkemp/gulp-inline-css/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/jonkemp/gulp-inline-css?branch=master)\n\n[![NPM](https://nodei.co/npm/gulp-inline-css.png?downloads=true)](https://nodei.co/npm/gulp-inline-css/)\n\n\u003e Inline your CSS properties into the `style` attribute in an html file. Useful for emails.\n\nInspired by the grunt plugin [grunt-inline-css](https://github.com/jgallen23/grunt-inline-css). Uses the [inline-css](https://github.com/jonkemp/inline-css) module.\n\n## What's new in 3.0?\n\n- Uses Promises with [inline-css](https://github.com/jonkemp/inline-css) version 2.0\n\n## How It Works\n\nThis gulp plugin takes an html file and inlines the CSS properties into the style attribute.\n\n`/path/to/file.html`:\n```html\n\u003chtml\u003e\n\u003chead\u003e\n  \u003cstyle\u003e\n    p { color: red; }\n  \u003c/style\u003e\n  \u003clink rel=\"stylesheet\" href=\"style.css\"\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n  \u003cp\u003eTest\u003c/p\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n`style.css`\n```css\np {\n  text-decoration: underline;\n}\n```\n\nOutput:\n```html\n\u003chtml\u003e\n\u003chead\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n  \u003cp style=\"color: red; text-decoration: underline;\"\u003eTest\u003c/p\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n## What is this useful for ?\n\n- HTML emails. For a comprehensive list of supported selectors see\n[here](http://www.campaignmonitor.com/css/)\n- Embedding HTML in 3rd-party websites.\n- Performance. Downloading external stylesheets delays the rendering of the page in the browser. Inlining CSS speeds up this process because the browser doesn't have to wait to download an external stylesheet to start rendering the page.\n\n\n## Install\n\nInstall with [npm](https://npmjs.org/package/gulp-inline-css)\n\n```\nnpm install --save-dev gulp-inline-css\n```\n\n\n## Usage\n\n```js\nvar gulp = require('gulp'),\n    inlineCss = require('gulp-inline-css');\n\ngulp.task('default', function() {\n    return gulp.src('./*.html')\n        .pipe(inlineCss())\n        .pipe(gulp.dest('build/'));\n});\n```\n\nWith options:\n\n```js\nvar gulp = require('gulp'),\n    inlineCss = require('gulp-inline-css');\n\ngulp.task('default', function() {\n    return gulp.src('./*.html')\n        .pipe(inlineCss({\n\t        \tapplyStyleTags: true,\n\t        \tapplyLinkTags: true,\n\t        \tremoveStyleTags: true,\n\t        \tremoveLinkTags: true\n        }))\n        .pipe(gulp.dest('build/'));\n});\n```\n\nOptions are passed directly to [inline-css](https://github.com/jonkemp/inline-css).\n\n\n## API\n\n### inlineCss(options)\n\n\n#### options.extraCss\n\nType: `String`  \nDefault: `\"\"`\n\nExtra css to apply to the file.\n\n\n#### options.applyStyleTags\n\nType: `Boolean`  \nDefault: `true`\n\nWhether to inline styles in `\u003cstyle\u003e\u003c/style\u003e`.\n\n\n#### options.applyLinkTags\n\nType: `Boolean`  \nDefault: `true`\n\nWhether to resolve `\u003clink rel=\"stylesheet\"\u003e` tags and inline the resulting styles.\n\n\n#### options.removeStyleTags\n\nType: `Boolean`  \nDefault: `true`\n\nWhether to remove the original `\u003cstyle\u003e\u003c/style\u003e` tags after (possibly) inlining the css from them.\n\n\n#### options.removeLinkTags\n\nType: `Boolean`  \nDefault: `true`\n\nWhether to remove the original `\u003clink rel=\"stylesheet\"\u003e` tags after (possibly) inlining the css from them.\n\n\n#### options.url\n\nType: `String`  \nDefault: `filePath`\n\nHow to resolve hrefs. **Required**.\n\n#### options.preserveMediaQueries\n\nType: `Boolean`  \nDefault: `false`\n\nPreserves all media queries (and contained styles) within `\u003cstyle\u003e\u003c/style\u003e` tags as a refinement when `removeStyleTags` is `true`. Other styles are removed.\n\n#### options.applyWidthAttributes\n\nType: `Boolean`  \nDefault: `false`\n\nWhether to use any CSS pixel widths to create `width` attributes on elements.\n\n#### options.applyTableAttributes\n\nType: `Boolean`  \nDefault: `false`\n\nWhether to apply the `border`, `cellpadding` and `cellspacing` attributes to `table` elements.\n\n#### options.removeHtmlSelectors\n\nType: `Boolean`  \nDefault: `false`\n\nWhether to remove the `class` and `id` attributes from the markup.\n\n#### options.codeBlocks\n\nType: `Object`  \nDefault: `{ EJS: { start: '\u003c%', end: '%\u003e' }, HBS: { start: '{{', end: '}}' } }`\n\nAn object where each value has a `start` and `end` to specify fenced code blocks that should be ignored during parsing and inlining. For example, Handlebars (hbs) templates are `HBS: {start: '{{', end: '}}'}`. `codeBlocks` can fix problems where otherwise inline-css might interpret code like `\u003c=` as HTML, when it is meant to be template language code. Note that `codeBlocks` is a dictionary which can contain many different code blocks, so don't do `codeBlocks: {...}` do `codeBlocks.myBlock = {...}`.\n\n### Special markup\n\n#### data-embed\n\nWhen a data-embed attribute is present on a \u003cstyle\u003e\u003c/style\u003e tag, inline-css will not inline the styles and will not remove the \u003cstyle\u003e\u003c/style\u003e tags.\n\nThis can be used to embed email client support hacks that rely on css selectors into your email templates.\n\n### cheerio options\n\nOptions to passed to [cheerio](https://github.com/cheeriojs/cheerio).\n\n## License\n\nMIT © [Jonathan Kemp](http://jonkemp.com)\n","funding_links":[],"categories":["插件","Plugins"],"sub_categories":["其他插件","Miscellaneous Plugins"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonkemp%2Fgulp-inline-css","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonkemp%2Fgulp-inline-css","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonkemp%2Fgulp-inline-css/lists"}