Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[build] Up compression quality #127064

Merged
merged 5 commits into from
Mar 8, 2022
Merged
Show file tree
Hide file tree
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
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 @@ -266,6 +266,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 @@ -283,7 +286,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