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

css-mqpacker-webpack-plugin

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

css-mqpacker-webpack-plugin

The Webpack plugin for pack same CSS media query rules into one using PostCSS

  • 0.16.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

css-mqpacker-webpack-plugin

npm version

The Webpack plugin for pack same CSS media query rules into one using PostCSS.

node-css-mqpacker

Before:

.foo {
  width: 240px;
}

@media (max-width: 768px) {
  .foo {
    width: 576px;
  }
}

.bar {
  width: 160px;
}

@media (max-width: 768px) {
  .bar {
    width: 384px;
  }
}

After:

.foo {
  width: 240px;
}

.bar {
  width: 160px;
}

@media (max-width: 768px) {
  .foo {
    width: 576px;
  }

  .bar {
    width: 384px;
  }
}

Install

npm i css-mqpacker-webpack-plugin --save-dev
# or
yarn add css-mqpacker-webpack-plugin -D

Example

webpack.config.js

const CssMqpackerPlugin = require('css-mqpacker-webpack-plugin');

module.exports = {
  optimization: {
    minimize: true,
    minimizer: [
      new CssMqpackerPlugin(),
    ],
  },
};

Options

test

Type: String|RegExp|Array<String|RegExp> Default: /\.css(\?.*)?$/i

Test to match files against.

webpack.config.js

module.exports = {
  optimization: {
    minimize: true,
    minimizer: [
      new CssMqpackerPlugin({
        test: /\.foo\.css$/i,
      }),
    ],
  },
};

include

Type: String|RegExp|Array<String|RegExp> Default: undefined

Files to include.

webpack.config.js

module.exports = {
  optimization: {
    minimize: true,
    minimizer: [
      new CssMqpackerPlugin({
        include: /\/includes/,
      }),
    ],
  },
};

exclude

Type: String|RegExp|Array<String|RegExp> Default: undefined

Files to exclude.

webpack.config.js

module.exports = {
  optimization: {
    minimize: true,
    minimizer: [
      new CssMqpackerPlugin({
        exclude: /\/excludes/,
      }),
    ],
  },
};

sort

Type: Boolean|Function Default: false

By default, CSS MQPacker pack and order media queries as they are defined (the “first win” algorithm). If you want to sort media queries automatically, pass sort: true.

webpack.config.js

module.exports = {
  optimization: {
    minimize: true,
    minimizer: [
      new CssMqpackerPlugin({
        sort: true,
      }),
    ],
  },
};

License

MIT

Keywords

FAQs

Package last updated on 30 Mar 2024

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