The Wayback Machine - https://web.archive.org/web/20200911020934/https://github.com/diegohaz/webpack-blocks-split-vendor
Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

webpack-blocks-split-vendor

Generated with nod NPM version Build Status Coverage Status

A webpack block that splits vendor javascript into separated bundle.

Install

$ npm install --save webpack-blocks-split-vendor

Usage

const { createConfig, env } = require('webpack-blocks')
const splitVendor = require('webpack-blocks-split-vendor')

module.exports = createConfig([
  // creates a vendor.js file (or vendor.[chunkhash].js in production)
  splitVendor(),

  // creates a foo.js file
  splitVendor('foo'), 

  // creates a foo.js file, but keeps offline-plugin/runtime out of vendor
  splitVendor({ name: 'foo', exclude: /offline-plugin\/runtime\.js/ })

  // creates a vendor.js file, but keeps lodash and offline-plugin/runtime out of vendor
  splitVendor({ exclude: [/lodash/, /offline-plugin\/runtime\.js/] })
])

How it does

  • changes the output filename to [name].[chunkhash].js;
  • creates a bundle with node_modules/**/*.js files with the help of CommonsChunkPlugin;
  • uses webpack-md5-hash instead of the standard webpack chunkhash so vendor bundle will have different hash from other bundles (otherwise, we would invalidate the vendor bundle cache everytime we update the app bundle, which would make this approach useless).

For more details, see src/index.js.

API

Table of Contents

splitVendor

Returns a webpack block that splits vendor javascript bundle.

Parameters

Returns Function

Condition

Type: (string | RegExp | Array<Condition>)

Options

Type: {name: string, test: Condition?, exclude: Condition?}

Properties

Other useful webpack blocks

License

MIT © Diego Haz

About

A webpack block that splits vendor javascript into separated bundle

Topics

Resources

License

Packages

No packages published
You can’t perform that action at this time.