postcss-font-grabber
Advanced tools
Comparing version 3.0.0 to 3.0.1
@@ -14,15 +14,16 @@ "use strict"; | ||
const FontExtensionsToMimeTypes = { | ||
woff: ['application/font-woff', 'font/woff'], | ||
woff2: ['application/font-woff2', 'font/woff2'], | ||
eot: ['application/vnd.ms-fontobject'], | ||
ttf: ['application/x-font-ttf', 'application/x-font-truetype'], | ||
otf: ['application/x-font-opentype', 'font/otf'], | ||
svg: ['image/svg+xml'], | ||
ttf: ['application/x-font-ttf', 'application/x-font-truetype'], | ||
woff: ['application/font-woff', 'font/woff'], | ||
woff2: ['application/font-woff2', 'font/woff2'], | ||
}; | ||
const FontExtensionsToFormats = { | ||
eot: 'embedded-opentype', | ||
otf: 'opentype', | ||
svg: 'svg', | ||
ttf: 'truetype', | ||
woff: 'woff', | ||
woff2: 'woff2', | ||
ttf: 'truetype', | ||
svg: 'svg', | ||
}; | ||
@@ -29,0 +30,0 @@ function isRemoteFontFaceDeclaration(node) { |
{ | ||
"name": "postcss-font-grabber", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "It grabs remote font files and update your CSS, just like that.", | ||
@@ -54,2 +54,4 @@ "author": "AaronJan <aaronjan@qq.com>", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^2.38.4", | ||
"rollup-plugin-postcss": "^4.0.0", | ||
"sinon": "^9.2.4", | ||
@@ -56,0 +58,0 @@ "style-loader": "^2.0.0", |
@@ -28,7 +28,6 @@ <h1 align=center> | ||
- Support custom download function (the `download` option) | ||
- Standalone without any dependency | ||
- Written in TypeScript | ||
- Standalone without any dependency | ||
- Download font files concurrently | ||
- Infer font file extension from HTTP response header (Thanks to [@FTWinston](https://github.com/FTWinston)) | ||
- Support custom download function (the `download` option) | ||
@@ -43,29 +42,2 @@ ## Installation | ||
## Options | ||
Function `postcssFontGrabber` takes an object of options as parameter, like: | ||
```javascript | ||
import { postcssFontGrabber } from 'postcss-font-grabber'; | ||
postcssFontGrabber({ | ||
cssSrc: 'src/css/', | ||
cssDest: 'dist/', | ||
fontDest: 'dist/fonts/', | ||
}); | ||
``` | ||
| Name | Type | Default | Description | | ||
| :------: | :----------------------------------------------------------------------: | :----------------------------------- | :-------------------------------------------------- | | ||
| cssSrc | `string` | `opts.from` from `PostCSS`'s setting | The root directory path of all CSS files | | ||
| cssDest | `string` | `opts.to` from `PostCSS`'s setting | The directory where the transpiled CSS files are in | | ||
| fontDest | `string` | the same as `cssDest` | The directory where the downloaded fonts stored | | ||
| download | `(fontSpec: FontSpec) => Promise<{ data: Readable, mimeType?: string }>` | - | Custom function to download font files | | ||
You can import types as shown above: | ||
```typescript | ||
import { FontSpec, Downloader, DownloadResult } from 'postcss-font-grabber'; | ||
``` | ||
## Usages | ||
@@ -96,5 +68,37 @@ | ||
### With Rollup | ||
> This example is using `Rollup 2` with: | ||
> | ||
> - [rollup-plugin-postcss](https://github.com/egoist/rollup-plugin-postcss) | ||
`rollup.config.js`: | ||
```javascript | ||
import postcss from 'rollup-plugin-postcss'; | ||
export default { | ||
input: 'src/main.js', | ||
output: { | ||
file: 'dist/bundle.js', | ||
format: 'cjs', | ||
}, | ||
plugins: [ | ||
postcss({ | ||
plugins: [ | ||
postcssFontGrabber({ | ||
// postcss-font-grabber needs to know the CSS output | ||
// directory in order to calculate the new font URL. | ||
cssDest: 'dist/', | ||
fontDest: 'dist/fonts/', | ||
}), | ||
], | ||
}), | ||
], | ||
}; | ||
``` | ||
### With Webpack | ||
> This example is using `Webpack 5` with these packages: | ||
> This example is using `Webpack 5` with: | ||
> | ||
@@ -156,6 +160,19 @@ > - [postcss-loader](https://github.com/postcss/postcss-loader) | ||
## Advanced Usages | ||
## Options | ||
TODO | ||
| Name | Type | Default | Description | | ||
| :------: | :----------------------------------------------------------------------: | :----------------------------------- | :------------------------------------------------------------------------------------------ | | ||
| cssSrc | `string` | `opts.from` from `PostCSS`'s setting | The root directory path of all CSS files | | ||
| cssDest | `string` | `opts.to` from `PostCSS`'s setting | The directory where the transpiled CSS files are in | | ||
| fontDest | `string` | the same as `cssDest` | The directory where the downloaded fonts stored | | ||
| download | `(fontSpec: FontSpec) => Promise<{ data: Readable, mimeType?: string }>` | - | Custom function to download font files. Maybe you want to customize UserAgent or something? | | ||
## TypeScript | ||
You can import types if you need to (only in TypeScript): | ||
```typescript | ||
import { FontSpec, Downloader, DownloadResult } from 'postcss-font-grabber'; | ||
``` | ||
## License | ||
@@ -162,0 +179,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
57585
561
185
22