2.1.0 • Published 1 year ago

postcss-media-query-importer v2.1.0

Weekly downloads
-
License
-
Repository
github
Last release
1 year ago

postcss-media-query-importer

A PostCSS plugin to easily manage media queries in your project. Define media queries and corresponding filenames in the plugin options. Then use @import-mq '[path-to-folder]' anywhere in your css.

To-Do

StatusTaskPriority
Example project filesHIGH
Option to merge queries when no file presentLOW
Fix TestsHIGH
Add parsing for media queries rangesLOW
Hot Reload when importing with svelte style tagMEDIUM
Overhaul Error/Warn HandlingLOW
Hot Reload AddedHIGH
Update DocsHIGH
Indexing option for importsHIGH
Parse aliases from urlsHIGH
Import aliases from configHIGH

Simple Example

InputOutput
Example Input CSSExample Output CSS

Example PostCSS Config

Postcss-media-query-importer can also include an "index" file when importing. See configuration for more details.

Usage & Installation

Step 1: Install the plugin:

npm install --save-dev postcss postcss-media-query-importer

Step 2: Add the plugin to plugins list and define your project media queries:

+ const postcssMediaQueryImporter = require('postcss-media-query-importer')

module.exports = {
  plugins: [
    require('autoprefixer'),
+    postcssMediaQueryImporter(
+       ...options  
+    ),
  ]
}

Step 3: In any postcss file or postcss <style> tag, use @import-mq 'path/to/folder'. The path can either be relative to the current file, or relative to the project root directory.


Configuration

Plugin Options

Import Settings

  • index: Import an additional folder index file along with media queries
  • aliases: Define aliases to be parsed out of import urls