npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

split-webpack-plugin

v1.1.0

Published

Automates division process of files to serve your webpack bundles

Downloads

2

Readme

split-webpack-plugin

Node version NPM version Build status

This is a webpack plugin for Automating segmentation process of files. That can be more helpful when we should split all files manually, especially using multiple third-party libraries. You can simply divide your files by size or the number of eventually segmented files.

This plugin works with webpack 1.x, 2.x and 3.x

Installation

npm install split-webpack-plugin -D

Usage

Add the plugin to webpack plugins configure:

var SplitPlugin = require('split-webpack-plugin');
var webpackConfig = {

    // ...

    plugins: [
        new SplitPlugin({
            size: 512 // 512 KB
        })
    ]
};

Configuration:

  • size: The size of each partitioned block, measured in KB

  • async: true | false default is true, the plugin uses require.ensure method to divide modules, so we simply insert entry chunk to html manually to startup our app. check example: async

    however if plugins has applied html-webpack-plugin in webpack, you can set option.async to false, html-webpack-plugin will put all segmented chunks into html template automatically:

    const DividePlugin = require('split-webpack-plugin');
    const HtmlPlugin = require('html-webpack-plugin');
    var webpackConfig = {
    
        entry: {
            app: './app.js'
        },
        // ...
    
        plugins: [
            new DivideWebpackPlugin({
                size: 512 // 512 KB,
                async: false
            }),
            new HtmlPlugin()
        ]
    };

    Automatically generated html would be like:

    <script type="text/javascript" src="divide-chunk_app0.js"></script>
    <script type="text/javascript" src="divide-chunk_app1.js"></script>
    <script type="text/javascript" src="app.js"></script>

    check example: sync.

  • chunks: specific entry chunks in segmentation process, default is all entries. e.g.Different config for different entries:

        const SplitPlugin = require('split-webpack-plugin');
        var webpackConfig = {
            entry: {
                app: './src/app.js',
                login: './src/login.js'
            },
            plugins: [
                new SplitPlugin({
                    chunks: ['app'],
                    size: 256 // 256 KB
                }),
                new SplitPlugin({
                    chunks: ['login'],
                    divide: 2
                })
            ]
        };
  • excludeChunks: skip these chunks from segmentation process

  • divide: The number of partitioned block which each files will be divided into. When option.divide greater than 1, split-webpack-plugin will ignore option.size.

css

When options.async:true, divide-plugin would't partition the files that have been processed by css-loader or style-loader, so the css files can be loaded immediately. but a better way is to use extract-text-webpack-plugin. check example: extract-css.

All css files are bundled into one file:

var webpackConfig = {
    plugins: [
        // ...
        new ExtractTextPlugin("styles.css")
    ]
};

Keep segmented css files:

var webpackConfig = {
    plugins: [
        // ...
        new ExtractTextPlugin("[name].css")
    ]
};