Skip to content

Instantly share code, notes, and snippets.

@pmdartus
Last active February 12, 2020 17:28
Show Gist options
  • Save pmdartus/f97b7895c39b66069365738c9ea7c65c to your computer and use it in GitHub Desktop.
Save pmdartus/f97b7895c39b66069365738c9ea7c65c to your computer and use it in GitHub Desktop.
Rollup configuration for size comparison
// Run via `yarn rollup -c rollup.config.js` at the root of the lwc repo
import path from 'path';
import replace from '@rollup/plugin-replace';
import { terser } from 'rollup-plugin-terser';
const input = path.resolve(__dirname, 'packages/lwc/dist/engine/esm/es2017/engine.js');
const replaceConfig = {
'process.env.NODE_ENV': JSON.stringify('production'),
};
const terserConfig = {
output: {
comments: false,
}
};
export default [
{
input,
output: {
file: 'dist/original.js',
},
},
{
input,
plugins: [replace(replaceConfig)],
output: {
file: 'dist/prod.js',
},
},
{
input,
plugins: [terser(terserConfig)],
output: {
file: 'dist/minified.js',
},
},
{
input,
plugins: [replace(replaceConfig), terser(terserConfig)],
output: {
file: 'dist/prod-minified.js',
},
},
];
Bundle name Parsing size (without gzip, KB) Download size (with gzip, in KB)
Original 193 42
Minified (terser) 64 19
Production (replace process.env.NODE_ENV) 143 34
Minified + Production (terser + replace process.env.NODE_ENV) 38 13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment