Skip to content

Commit

Permalink
[build] Up compression quality (elastic#127064)
Browse files Browse the repository at this point in the history
* [build] Up compression quality

* update snapshot
  • Loading branch information
jbudz authored and azasypkin committed Jun 30, 2023
1 parent 2a0d32b commit 81feb23
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/kbn-babel-preset/node_preset.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports = (_, options = {}) => {
// Because of that we should use for that value the same version we install
// in the package.json in order to have the same polyfills between the environment
// and the tests
corejs: '3.2.1',
corejs: '3.21.1',
bugfixes: true,

...(options['@babel/preset-env'] || {}),
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-babel-preset/webpack_preset.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = () => {
modules: false,
// Please read the explanation for this
// in node_preset.js
corejs: '3.2.1',
corejs: '3.21.1',
bugfixes: true,
},
],
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion packages/kbn-optimizer/src/worker/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ export function getWebpackConfig(bundle: Bundle, bundleRefs: BundleRefs, worker:
filename: '[path].br',
test: /\.(js|css)$/,
cache: false,
compressionOptions: {
level: 11,
},
}),
new CompressionPlugin({
algorithm: 'gzip',
Expand All @@ -272,7 +275,7 @@ export function getWebpackConfig(bundle: Bundle, bundleRefs: BundleRefs, worker:
extractComments: false,
parallel: false,
terserOptions: {
compress: true,
compress: { passes: 2 },
keep_classnames: true,
mangle: true,
},
Expand Down
15 changes: 12 additions & 3 deletions src/dev/build/tasks/generate_packages_optimized_assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import terser from 'terser';
import vfs from 'vinyl-fs';
import globby from 'globby';
import del from 'del';
import zlib from 'zlib';

import { Task, write } from '../lib';

Expand Down Expand Up @@ -55,21 +56,29 @@ async function optimizeAssets(log: ToolingLog, assetDir: string) {
log.debug('Minify JS');
await asyncPipeline(
vfs.src(['**/*.js'], { cwd: assetDir }),
gulpTerser({ compress: true, mangle: true }, terser.minify),
gulpTerser({ compress: { passes: 2 }, mangle: true }, terser.minify),
vfs.dest(assetDir)
);

log.debug('Brotli compress');
await asyncPipeline(
vfs.src(['**/*.{js,css}'], { cwd: assetDir }),
gulpBrotli(),
gulpBrotli({
params: {
[zlib.constants.BROTLI_PARAM_QUALITY]: zlib.constants.BROTLI_MAX_QUALITY,
},
}),
vfs.dest(assetDir)
);

log.debug('GZip compress');
await asyncPipeline(
vfs.src(['**/*.{js,css}'], { cwd: assetDir }),
gulpGzip(),
gulpGzip({
gzipOptions: {
level: 9,
},
}),
vfs.dest(assetDir)
);
} finally {
Expand Down

0 comments on commit 81feb23

Please sign in to comment.