Skip to content

Instantly share code, notes, and snippets.

@phlcastro
Created September 28, 2016 02:51
Show Gist options
  • Save phlcastro/47e3462c6764d2ede52fbf08b299ce59 to your computer and use it in GitHub Desktop.
Save phlcastro/47e3462c6764d2ede52fbf08b299ce59 to your computer and use it in GitHub Desktop.
Use of CommonsChunkPlugin on webpack
import React from 'react';
import ReactDom from 'reactDom';
var CommonsChunkPlugin = require("webpack/lib/optimize/CommonsChunkPlugin");
var node_dir = __dirname + '/node_modules';
module.exports = {
resolve: {
alias: {
react: node_dir + '/react',
reactDom: node_dir + '/react-dom'
}
},
entry: {
vendors: ['react','reactDom'],
my_entry: './my_entry.jsx'
},
output: {
path: './my_output_path',
filename: '[name].bundle.js'
},
plugins: [
new CommonsChunkPlugin('vendors', 'common.js', Infinity)
],
module: {
loaders: [
{
test: /.jsx$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: ['es2015', 'react', 'stage-2']
}
}
]
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment