pp

postcss-print

PostCSS plugin to extract all print css into a separated file.

Showing:

Popularity

Downloads/wk

1

Maintenance

No Maintenance Data Available

Package

Dependencies

1

Size (min+gzip)

23.3KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Deprecated!
WARNING: This project has been renamed to postcss-extract-media. Install using npm install postcss-extract-media. This project won't be supported anymore

Readme

postcss-print

PostCSS plugin to extract all @media print from your stylesheets and move it to a print.css file

This is really specific for my needs right now and it may evolve for a better opensource plugin, but right now I don't really recommend it's use, as it's not even tested.

Installation

npm install postcss-print

How to use

Options

generate (default: false)

This is the option that generates the new print.css file, I use it like this (with Grunt):

generatePrint: {
    options: {
        processors: [
            require('postcss-print')({ generate: true })
        ]
    },
    src  : 'public/css/dist/all.min.css',
    dest : 'public/css/dist/print.css'
}

pure (default: false)

This option removes all occurences of @media print from your original css files. I use it like this (with Grunt):

removePrint: {
    options: {
        processors: [
            require('postcss-print')({ remove: true })
        ]
    },
    src: 'public/css/dist/*.min.css'
}

Using

Plugin can be used just like any other PostCSS plugin. For example, Gulp setup (using gulp-postcss). Or Grunt setup (using grunt-postcss):

module.exports = function(grunt) {
    grunt.config('postcss', {
        prefix: {
            options: {
                map  : true,
                diff : true,
                processors: [
                    require('autoprefixer-core')({ browsers: ['> 1%', 'last 1 version', 'ie 8', 'ie 9'] })
                ]
            },
            src: 'public/css/dist/*.css'
        },
        generatePrint: {
            options: {
                processors: [
                    require('postcss-print')({ generate: true })
                ]
            },
            src  : 'public/css/dist/all.min.css',
            dest : 'public/css/dist/print.css'
        },
        removePrint: {
            options: {
                processors: [
                    require('postcss-print')({ remove: true })
                ]
            },
            src: 'public/css/dist/*.min.css'
        }
    });

    grunt.loadNpmTasks('grunt-postcss');
};

And then use the print.css like this:

<link rel="stylesheet" href="print.css" media="print">

License

MIT © Gustavo Siqueira

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100