Example: Explicit Vendor Bundle

Creates a separate vendor bundle.

const path = require( 'path' )
const webpack = require('webpack')

// the project root
context( projectDir )

// We have two entry points
entry( {
  main: './src/index.js',,
  vendor: ['jquery', 'lodash', 'jsdom']
} )

// spit out main-bundle.js and vendor-bundle.js
output( () => {
  filename( '[name]-bundle.js' )
  path$( 'dist' )
} )

// tell webpack how to find jquery
resolve( () => {
  alias( { jquery: 'jquery/src/jquery' } )
} )

plugin( new webpack.ProvidePlugin( {
  $: 'jquery',
  jQuery: 'jquery'
} ) )

// pull out vendor items into a separate bundle
plugin( new webpack.optimize.CommonsChunkPlugin( {
  name: 'vendor',
  minChunks: Infinity
} ) )

Configure Webpack

Create a webpack.config.js in your project’s root and add:

const webpkr = require('webpkr');
module.exports = webpkr({projectDir: __dirname});