Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 56 additions & 6 deletions superset-frontend/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ const {
devserverPort = 9000,
measure = false,
analyzeBundle = false,
analyzerPort = 8888,
nameChunks = false,
} = parsedArgs;
const isDevMode = mode !== 'production';

Expand Down Expand Up @@ -197,13 +199,61 @@ const config = {
sideEffects: true,
splitChunks: {
chunks: 'all',
name: nameChunks,
automaticNameDelimiter: '-',
minChunks: 2,
cacheGroups: {
default: false,
major: {
name: 'vendors-major',
test: /\/node_modules\/(brace|react|react-dom|@superset-ui\/translation|webpack.*|@babel.*)\//,
automaticNamePrefix: 'chunk',
// basic stable dependencies
vendors: {
priority: 50,
name: 'vendors',
test: new RegExp(
`/node_modules/(${[
'abortcontroller-polyfill',
'react',
'react-dom',
'prop-types',
'redux',
'react-redux',
'react-hot-loader',
'react-select',
'react-sortable-hoc',
'react-virtualized',
'react-table',
'@hot-loader.*',
'webpack.*',
'@?babel.*',
'lodash.*',
'antd',
'@ant-design.*',
'.*bootstrap',
'moment',
'jquery',
'core-js.*',
'@emotion.*',
'd3.*',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this may also pull the one-time-use packages (that are not part of core d3) such as d3-sankey d3-cloud

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll make further tuning in this space in future PRs.

].join('|')})/`,
),
},
// bundle large libraries separately
brace: {
name: 'brace',
test: /\/node_modules\/(brace|react-ace)\//,
priority: 40,
},
mathjs: {
name: 'mathjs',
test: /\/node_modules\/mathjs\//,
priority: 30,
enforce: true,
},
// viz thumbnails are used in `addSlice` and `explore` page
thumbnail: {
name: 'thumbnail',
test: /thumbnail(Large)?\.png/i,
priority: 20,
enforce: true,
},
},
},
Expand Down Expand Up @@ -299,7 +349,7 @@ const config = {
},
],
},
/* for css linking images */
/* for css linking images (and viz plugin thumbnails) */
{
test: /\.png$/,
loader: 'url-loader',
Expand Down Expand Up @@ -404,7 +454,7 @@ if (isDevMode) {
// Pass flag --analyzeBundle=true to enable
// e.g. npm run build -- --analyzeBundle=true
if (analyzeBundle) {
config.plugins.push(new BundleAnalyzerPlugin());
config.plugins.push(new BundleAnalyzerPlugin({ analyzerPort }));
}

// Speed measurement is disabled by default
Expand Down