Created
December 29, 2016 20:07
-
-
Save gavindoughtie/095cfee4f9d59c9cc5d115d9a31cefb9 to your computer and use it in GitHub Desktop.
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 path from 'path'; | |
import util from 'util'; | |
import HtmlWebpackPlugin from 'html-webpack-plugin'; | |
import webpack from 'webpack'; | |
// The full paths to our various directories | |
const PATHS = {}; | |
['lib', 'build'].forEach((pathName) => { | |
PATHS[pathName] = path.join(__dirname, pathName); | |
}); | |
const uiVendorEntries = [ | |
'babel-polyfill', | |
'react', | |
'react-dom', | |
]; | |
const dataVendorEntries = [ | |
'immutable', | |
'redux', | |
'react-redux' | |
] | |
module.exports = { | |
entry: | |
{ | |
ui_module: uiVendorEntries, | |
data_module: dataVendorEntries, | |
app: path.join(PATHS.lib, 'index.js') | |
}, | |
resolve: { | |
extensions: ['.js', '.jsx'] | |
}, | |
output: | |
{ | |
path: PATHS.build, | |
filename: '[name].[hash].js', | |
chunkFilename: '[name].[chunkhash].js', | |
publicPath: '' | |
}, | |
module: | |
{ | |
rules: | |
[ { | |
test: /\.jsx?$/, | |
use: [ { | |
loader: 'babel-loader', options: { | |
cacheDirectory: true | |
} | |
} ], | |
include: PATHS.lib | |
}], | |
}, | |
plugins: | |
[ | |
new webpack.DefinePlugin({ | |
'process.env.NODE_ENV': '"production"' | |
}), | |
new HtmlWebpackPlugin({ | |
title: 'multi-vendor-bundles', | |
chunks: ['app'], | |
chunkNames: ['manifest'] | |
}), | |
new webpack.optimize.CommonsChunkPlugin({ | |
names: ['ui_module', 'data_module', 'manifest'], | |
minChunks: Infinity | |
}), | |
], | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment