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
16 changes: 15 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,16 +185,30 @@ var config = {
'#cheap-module-eval-source-map'
};


function hasZopfli() {
Copy link
Member

Choose a reason for hiding this comment

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

fwiw we probably need this in getsentry and sentry-plugins, or we need to not use zopfli in those

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll replicate this to sentry-plugins too.

For some reason, it's not explicitly used for getsentry, so it doesn't need to go there, but we should probably add this snippet anyways to precompress there.

return (
// npm@2
fs.existsSync('node_modules/compression-webpack-plugin/node_modules/node-zopfli') ||
// npm@3
fs.existsSync('node_modules/node-zopfli')
);
}

// This compression-webpack-plugin generates pre-compressed files
// ending in .gz, to be picked up and served by our internal static media
// server as well as nginx when paired with the gzip_static module.
if (IS_PRODUCTION) {
var algorithm = hasZopfli() ? 'zopfli' : 'gzip';
config.plugins.push(new (require('compression-webpack-plugin'))({
// zopfli gives us a better gzip compression
// See: http://googledevelopers.blogspot.com/2013/02/compress-data-more-densely-with-zopfli.html
algorithm: 'zopfli',
algorithm: algorithm,
regExp: /\.(js|map|css|svg|html|txt|ico|eot|ttf)$/,
}));
if (algorithm === 'gzip') {
console.warn('!! missing node-zopfli, so falling back to gzip.');
}
}

module.exports = config;