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

mini-css-extract-plugin

Package Overview
Dependencies
Maintainers
5
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mini-css-extract-plugin

extracts CSS into separate files

  • 2.4.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12M
decreased by-8.39%
Maintainers
5
Weekly downloads
 
Created

What is mini-css-extract-plugin?

The mini-css-extract-plugin is a plugin for webpack that extracts CSS into separate files. It creates a CSS file per JS file which contains CSS. It supports on-demand-loading of CSS and SourceMaps. It requires webpack 4 to function.

What are mini-css-extract-plugin's main functionalities?

Extract CSS into separate files

This feature allows you to extract CSS from your bundle into a separate file, which can be loaded independently.

const MiniCssExtractPlugin = require('mini-css-extract-plugin');

module.exports = {
  module: {
    rules: [
      {
        test: /\.css$/,
        use: [
          MiniCssExtractPlugin.loader,
          'css-loader'
        ]
      }
    ]
  },
  plugins: [
    new MiniCssExtractPlugin({
      filename: '[name].css',
      chunkFilename: '[id].css'
    })
  ]
};

Lazy loading of CSS files

This feature enables on-demand loading of CSS by splitting the CSS into chunks and loading them when needed.

import(/* webpackChunkName: 'style' */ './style.css').then(() => {
  // Use style.css
});

SourceMap support

This feature allows you to generate source maps for the CSS files, which is helpful for debugging purposes.

const MiniCssExtractPlugin = require('mini-css-extract-plugin');

module.exports = {
  module: {
    rules: [
      {
        test: /\.css$/,
        use: [
          {
            loader: MiniCssExtractPlugin.loader,
            options: {
              sourceMap: true
            }
          },
          {
            loader: 'css-loader',
            options: {
              sourceMap: true
            }
          }
        ]
      }
    ]
  },
  plugins: [
    new MiniCssExtractPlugin({
      filename: '[name].css',
      chunkFilename: '[id].css'
    })
  ]
};

Other packages similar to mini-css-extract-plugin

Keywords

FAQs

Package last updated on 07 Oct 2021

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