Giter Club home page Giter Club logo

grunt-legacssy's Introduction

grunt-legacssy DEPRECATED

Fix your CSS for legacy browsers

Getting Started

If you are looking for standalone version, you can use legacssy.

This plugin requires Grunt ~0.4.0

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-legacssy --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-legacssy');

The "legacssy" task

Overview

Run this task with the grunt legacssy command.

The task concats provided styles and when it finds unsupported (i.e. CSS3) @media query it tests the min-width and max-width and if it matches the rules inside the @media are included in the resulting style.

Task targets, files and options may be specified according to the grunt Configuring tasks guide.

Options

legacyWidth

type: Number Default: 1024

matchingOnly

Type: Boolean Default: True

Unsupported media queries are flattened only if their min-width and max-width match with legacyWidth. Comparison is number only, that means it is compatible with both px's and em's as long as there is only one of them used.

overridesOnly

Type: Boolean Default: False

Please note this might change the desired outcome, see the corresponding issue comment.

Usage Examples

Default Options

grunt.initConfig({
  legacssy: {
    dist: {
      files: {
        'css/style-legacy.css': 'css/style.css',
      },
    },
  },
})

Default Options

grunt.initConfig({
  legacssy: {
    dist: {
      options: {
        // Include only styles for a screen 800px wide
        legacyWidth: 800
      },
      files: {
        'css/style-legacy.css': 'css/style.css',
      },
    },
  },
})

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Release History

  • v0.4.0 Add colours and report to the output
  • v0.3.0 Output only overrides
  • v0.2.0   Media matching added * v0.1.0   Initial task with basic functionality.

Bitdeli Badge

grunt-legacssy's People

Contributors

2ndkauboy avatar bitdeli-chef avatar jirinovak avatar orthographic-pedant avatar robinpokorny avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

grunt-legacssy's Issues

Smart @media matching

Flatten only @media rules that are not supported in legacy browsers.

The idea is that in the options one could specify the legacy width – the tool would then include styles only with matching min-width etc. It would be OK to support only pixels.

Remove some prefixes

Identify and remove rules which uses some prefixes (e.g. -webkit- (?) ) as legacy browsers may not support them.

Doesn't recognise files unless I specify a target

I tried the format in the example:

legacssy: {
    files: {
        'css/main-legacy.css': 'css/main.css'
    }
}

but got the message: >> Destination not written because no source files were provided.

When I specify a target it works:

legacssy: {
    dist: {
        files: {
            'css/main-legacy.css': 'css/main.css'
        }
    }
}

Would be good to update the example to use a target unless it should actually work without one, thanks.

Option to contain *only* styles hidden in Media Queries in style-legacy.css

I mean this scenario:

<link rel="stylesheet" href="css/style.css">
<!--[if lte IE 8]><link rel="stylesheet" href="css/style-legacy.css"> <![endif]-->

Why?

  • In most projects I prefer this way because it doesn't require the closing of default CSS file in the comments.
  • I have project where I want to give user the choice of whether to support IE8 or not. Supporting IE8 can be done by adding one <link…> in HTML file then.

It could be done as option in grunt-legacssy.

Issue with using pixel ratio media queries

For example Chosen.js uses this @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min-resolution: 144dpi) and Legacssy is collapsing this media query even though they should not be.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.