cartodb.js and deep-insights.js in their own chunk.

pull/12065/head
nobuti 8 years ago
parent 8cfc5763cb
commit 982c6f30c6

1
.gitignore vendored

@ -73,3 +73,4 @@ doc/manual/build
/.tags_swap
.vscode/
/private_gears
/dist

@ -89,6 +89,7 @@
"uglify-js": "2.7.x",
"watchify": "3.7.0",
"webpack": "2.2.1",
"webpack-bundle-analyzer": "^2.4.0",
"webpack-stats-plugin": "0.1.4"
},
"browserify": {

@ -1,8 +1,15 @@
const webpack = require('webpack');
const {resolve} = require('path');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const PACKAGE = require('./package.json');
const version = PACKAGE.version;
const isProduction = process.env.NODE_ENV === 'production';
const internalDepsFilter = (module, count) => {
return module.resource && /cartodb.js|deep-insights.js/.test(module.resource);
};
module.exports = env => {
return {
entry: {
@ -11,18 +18,28 @@ module.exports = env => {
editor: './lib/assets/core/javascripts/cartodb3/editor.js'
},
output: {
filename: `${version}/[name].js`,
filename: `${version}/[name].[chunkhash].js`,
path: resolve(__dirname, 'dist')
},
devtool: isProduction ? 'source-map' : 'eval-source-map',
plugins: [
isProduction ? undefined : new BundleAnalyzerPlugin({
analyzerMode: 'static'
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: function (module) {
// this assumes your vendor imports exist in the node_modules directory
return module.context && module.context.indexOf('node_modules') !== -1;
}
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'common',
minChunks: internalDepsFilter
})
],
].filter(p => !!p), // undefined is not a valid plugin, so filter undefined values here
module: {
rules: [
{

Loading…
Cancel
Save