Extract inline CSS from HTML
npm install extract-inline-cssExtract and replace inline CSS with classnames.
``bash`
$ yarn add -D extract-inline-css
`js
import extract from 'extract-inline-css';
extract('./index.html', {
dist: './dist'
});
`
This will generate extracted.css and result.html files inside dist/ directory.
If you want to get results in string format, set out: 'object' option:
`js
import extract from 'extract-inline-css';
const { css, html } = extract('./index.html', {
out: 'object'
});
`
`html`
Hello world!
result.html
`html`
Hello world!
extracted.css
`css
body {
background: #bada55;
}
.h1_g4q7h2 {
font-size: 22px;
line-height: 1.2;
}
`
| Option | Type | Default | Description |
| ------------------- | -------------------------- | --------------- | ---------------------------------------------- |
| cssFilename | string | extracted.css | Filename of the resulting CSS file |string
| dist | | . | Output directory path |boolean
| extractGlobalStyles | | true | Extract CSS from