1.0.24 • Published 3 years ago

extract-media-query-plugin v1.0.24

Weekly downloads
29
License
MIT
Repository
github
Last release
3 years ago

Extract-Meida-Query-Plugin

A webpack plugin which extracts media queries from all your compiled css into a separate file and sorts them by breakpoints and groups

Installation

npm i extract-media-query-plugin

yarn add extract-media-query-plugin

Usage

In your webpack.config.js rules section

const { ExtractMediaQueriesPlugin } = require("extract-media-query-plugin");

  {
    test: /\.scss$/i,
    use: [MiniCssExtractPlugin.loader, "css-loader", "sass-loader"],
  }

and in your plugins

  plugins: [
    new HtmlWebpackPlugin({
        template: path.resolve(__dirname, "src", "index.html"),
    }),
    new ExtractMediaQueriesPlugin({
        fileName: "queries.css", // this is the default filename
    }),
    new MiniCssExtractPlugin({
        linkType: "text/css",
    }),
  ]

Keep in mind that the plugin is used along with MiniCssExtractPlugin.loader and css-loader. Also, MiniCssExtractPlugin was used to extract styles to later process by the plugin as well as HtmlWebpackPlugin to insert the newly created stylesheet into the html. I am not sure how it will work with other setups if it will :) However, you can you less-loader or other loaders to process your styles, just bear in mind that this plugin relies on the fact that all your styles have been processed and emitted as a separate stylesheet.

Contributing

Pull requests are welcome.

1.0.24

3 years ago

1.0.23

3 years ago

1.0.22

3 years ago

1.0.21

3 years ago

1.0.19

3 years ago

1.0.20

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago