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

filter-chunk-webpack-plugin

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

filter-chunk-webpack-plugin

Include or exclude files / chunks from the final webpack output based on a list of patterns

  • 2.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

filter-chunk-webpack-plugin

Include or exclude files / chunks from the final webpack output based on a list of patterns

npm Build Status Coverage Status PRs Welcome

This webpack plugin allows you to filter the list of output files before they are being written / emitted to disk. It does not prevent files from import or require from being processed and bundled, keeping the file references like image assets in your bundled code.

This is useful if you're creating multiple output bundles with common assets. As such, you can use this to omit it in other runs.

Installation

Install the library via:

npm install filter-chunk-webpack-plugin --save-dev

Tested Versions

WebpackPackage Version
4.x.x> 2.x.x
3.x.x1.x.x

Basic Usage

const ExtractTextPlugin = require('extract-text-webpack-plugin');
const FilterChunkWebpackPlugin = require('filter-chunk-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const path = require('path');

const webpackConfig = {
  entry: 'index.js',
  output: {
    path: path.join(__dirname, 'dist'),
    filename: 'assets/app.[chunkhash].js'
  },
  module: {
    rules: [{
      test: /\.css$/,
      use: [
        MiniCssExtractPlugin.loader,
        "css-loader"
      ]
    }, {
      test: /\.svg$/,
      use: {
        loader: 'file-loader',
        options: {
          name: '[hash].[ext]',
          outputPath: 'assets/images/'
        }
      }
    }]
  },
  plugins: [
    new MiniCssExtractPlugin({
      filename: "assets/css/[contenthash].css",
      chunkFilename: "assets/css/[id].css"
    })
    new FilterChunkWebpackPlugin({
      patterns: [
        'assets/*',
        '!assets/css/*'
      ]
    })
  ]
};

This should generate files like

assets/app.12ab3c.js
assets/css/css.98a5a.css

but not

assets/images/a5b912cd3.svg

For more information, check out the usage.spec.js.

Options

optionstypedefaultdescription
patternsarray[]A list of pattern types that are supported by multimatch
selectbooleanfalseBy default, this plugin will omit the matched result. Setting this to true will include the matched result instead of omitting them

License

filter-chunk-webpack-plugin is MIT licensed

Keywords

FAQs

Package last updated on 05 Aug 2018

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