Created
September 28, 2016 02:51
-
-
Save phlcastro/47e3462c6764d2ede52fbf08b299ce59 to your computer and use it in GitHub Desktop.
Use of CommonsChunkPlugin on webpack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import ReactDom from 'reactDom'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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