Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

postcss-font-grabber

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-font-grabber

Grab remote font in @font-face, download it and update your CSS, end of story.

  • 1.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.6K
decreased by-0.73%
Maintainers
1
Weekly downloads
 
Created
Source

PostCSS Font Grabber

Build Status Coverage Status

This is a PostCSS plugin, only do one thing:

Grab remote font in @font-face, download it and update your CSS.

Boom.

Example

Before using:

@font-face {
    font-family : 'beautiful-font';
    src         : url('https://font-site.com/beautiful-font.woff');
}

After using:

@font-face {
    font-family : 'beautiful-font';
    src         : url('local-font/beautiful-font.woff');
}

And of cource, the beautiful-font.woff file is in your local-font/ folder now.

Usage

Gulp

gulp.task('css', function () {
    var postcss            = require('gulp-postcss');
    var postcssFontGrabber = require('postcss-font-grabber');

    return gulp.src('src/**/*.css')
        .pipe(postcss([
            postcssFontGrabber() // I'm here
        ]))
        .pipe(gulp.dest('build/'));
});

Webpack

Use postcss-loader:

import postcssFontGrabber from 'postcss-font-grabber';

module.exports = {
    module: {
        loaders: [
            {
                test:   /\.css$/,
                loader: "style-loader!css-loader!postcss-loader"
            },

            //
            // Let Webpack support font file
            //
            {
                test: /\.(svg|ttf|eot|woff|woff2)$/,
                loader: 'file-loader'
            }
        ]
    },
    postcss: () => {
        return [
            postcssFontGrabber() // I'm here
        ];
    }
}

Options

Function postcssFontGrabber takes an object of options as parameter:

postcssFontGrabber({ dirPath: '../css/build/font/' })

dirPath

Type: String

The folder to save font file to, it's the same folder as the output CSS file is in by default.

Roadmap

  1. Grab local file.

  2. Rename font file name automatically (Configurable).

  3. Just replace the rule, do not download the font file.

License

Licensed under the APACHE LISENCE 2.0.

Credits

PostCSS PostCSS Copy Assets

Keywords

FAQs

Package last updated on 24 May 2016

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc