Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
postcss-font-grabber
Advanced tools
It grabs remote font files and update your CSS, just like that.
3.x
is under active development.
A postcss
plugin, it grabs remote font files and update your CSS, just like that.
postcss-font-grabber
v3.x
only works withpostcss
v8
,forpostcss
v7
, please take a look at thev2.x
.
You may not want to use remote fonts, because:
download
option)Requires:
Node >= 8.0
,postcss 8.*
npm install postcss postcss-font-grabber --save-dev
import { postcssFontGrabber, FontSpec } from 'postcss-font-grabber';
import { Readable } from 'stream';
postcssFontGrabber({
// The path of the source CSS directory.
// Normally you don't have to set this.
cssSrc: 'src/css/',
// The path of the CSS output directory.
// You have to specify this manually, PFG needs this to calculate relative
// path.
cssDest: 'src/css/',
// The directory to store the downloaded font files.
// It's the same as `cssDest` by default.
fontDest: 'tmp/css/fonts/',
// Custom function to download font files.
// Optional.
download: async (fontSpec: FontSpec) => ({
data: Readable.from(['font file content']),
mimeType: 'application/font-woff2',
}),
}),
gulp.task('css', () => {
const postcss = require('gulp-postcss');
const { postcssFontGrabber } = require('postcss-font-grabber');
return gulp
.src('src/css/**/*.css')
.pipe(
postcss([
postcssFontGrabber({
// postcss-font-grabber needs to know the CSS output
// directory in order to calculate the new font URL.
cssDest: 'dist/',
fontDest: 'dist/fonts/',
}),
]),
)
.pipe(gulp.dest('dist/'));
});
This example is using
Webpack 4
with these packages:
webpack.config.js
:
import path from 'path';
module.exports = {
entry: './src/index.js',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist'),
},
module: {
rules: [
{
test: /\.css$/,
exclude: /node_modules/,
use: [
{
loader: 'style-loader',
},
{
loader: 'css-loader',
options: {
importLoaders: 1,
},
},
{
loader: 'postcss-loader',
},
],
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/,
use: ['file-loader'],
},
],
},
};
postcss.config.js
:
import postcssFontGrabber from 'postcss-font-grabber';
module.exports = {
plugins: [
postcssFontGrabber({
cssSrc: 'src/css/',
// When using with `Webpack` you must set `cssDest` as the same as `cssSrc`
// since `Webpack` doesn't output CSS files directly, when done with
// `PostCSS`, `Webpack` use `file-loader` to transpile local file
// references in the CSS.
cssDest: 'src/css/',
fontDest: 'tmp/css/fonts/',
}),
],
};
PostCSS-Font-Grabber
will use from
and to
options of PostCSS
setting as the default options of cssSrc
(from
), cssDest
and fontDest
(to
).
Function postcssFontGrabber
takes an object of options as parameter:
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 |
mkdir | {boolean} | true | whether to create non-existing directories automatically or not |
TODO
Licensed under the APACHE LISENCE 2.0.
FAQs
It grabs remote font files and update your CSS, just like that.
The npm package postcss-font-grabber receives a total of 1,567 weekly downloads. As such, postcss-font-grabber popularity was classified as popular.
We found that postcss-font-grabber demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.