mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
# Backport This will backport the following commits from `main` to `8.11`: - [Remove webpack compression plugin on v4 (#170203)](https://github.com/elastic/kibana/pull/170203) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Tiago Costa","email":"tiago.costa@elastic.co"},"sourceCommit":{"committedDate":"2023-11-02T17:11:48Z","message":"Remove webpack compression plugin on v4 (#170203)\n\nCloses https://github.com/elastic/kibana/issues/170202\r\n\r\nThis PR fixes a problem with brotli generated assets when creating an\r\nexternal plugin by replacing the brotli assets generated by webpack with\r\nthe ones created separately with gulp brotli.","sha":"ecdd1f090b5d29ca29fd8fcbbcf179d5812cadb8","branchLabelMapping":{"^v8.12.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["chore","Team:Operations","release_note:skip","backport:prev-minor","v8.12.0"],"number":170203,"url":"https://github.com/elastic/kibana/pull/170203","mergeCommit":{"message":"Remove webpack compression plugin on v4 (#170203)\n\nCloses https://github.com/elastic/kibana/issues/170202\r\n\r\nThis PR fixes a problem with brotli generated assets when creating an\r\nexternal plugin by replacing the brotli assets generated by webpack with\r\nthe ones created separately with gulp brotli.","sha":"ecdd1f090b5d29ca29fd8fcbbcf179d5812cadb8"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.12.0","labelRegex":"^v8.12.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/170203","number":170203,"mergeCommit":{"message":"Remove webpack compression plugin on v4 (#170203)\n\nCloses https://github.com/elastic/kibana/issues/170202\r\n\r\nThis PR fixes a problem with brotli generated assets when creating an\r\nexternal plugin by replacing the brotli assets generated by webpack with\r\nthe ones created separately with gulp brotli.","sha":"ecdd1f090b5d29ca29fd8fcbbcf179d5812cadb8"}}]}] BACKPORT--> Co-authored-by: Tiago Costa <tiago.costa@elastic.co>
This commit is contained in:
parent
e2f99d4d9b
commit
3e367aadf8
8 changed files with 61 additions and 69 deletions
|
@ -1291,7 +1291,6 @@
|
|||
"@types/chromedriver": "^81.0.2",
|
||||
"@types/classnames": "^2.2.9",
|
||||
"@types/color": "^3.0.3",
|
||||
"@types/compression-webpack-plugin": "^2.0.2",
|
||||
"@types/cytoscape": "^3.14.0",
|
||||
"@types/d3": "^3.5.43",
|
||||
"@types/d3-array": "^2.12.1",
|
||||
|
@ -1319,7 +1318,6 @@
|
|||
"@types/geojson": "^7946.0.10",
|
||||
"@types/getos": "^3.0.0",
|
||||
"@types/gulp": "^4.0.6",
|
||||
"@types/gulp-zip": "^4.0.1",
|
||||
"@types/hapi__cookie": "^10.1.3",
|
||||
"@types/hapi__h2o2": "^8.3.3",
|
||||
"@types/hapi__hapi": "^20.0.9",
|
||||
|
@ -1454,7 +1452,6 @@
|
|||
"chromedriver": "^119.0.0",
|
||||
"clean-webpack-plugin": "^3.0.0",
|
||||
"cli-table3": "^0.6.1",
|
||||
"compression-webpack-plugin": "^4.0.0",
|
||||
"copy-webpack-plugin": "^6.0.2",
|
||||
"cpy": "^8.1.1",
|
||||
"css-loader": "^3.4.2",
|
||||
|
@ -1507,7 +1504,6 @@
|
|||
"gulp-postcss": "^9.0.1",
|
||||
"gulp-sourcemaps": "2.6.5",
|
||||
"gulp-terser": "^2.1.0",
|
||||
"gulp-zip": "^5.0.2",
|
||||
"has-ansi": "^3.0.0",
|
||||
"hdr-histogram-js": "^1.2.0",
|
||||
"html": "1.0.0",
|
||||
|
|
|
@ -15,7 +15,6 @@ import webpack from 'webpack';
|
|||
import TerserPlugin from 'terser-webpack-plugin';
|
||||
import webpackMerge from 'webpack-merge';
|
||||
import { CleanWebpackPlugin } from 'clean-webpack-plugin';
|
||||
import CompressionPlugin from 'compression-webpack-plugin';
|
||||
import UiSharedDepsNpm from '@kbn/ui-shared-deps-npm';
|
||||
import * as UiSharedDepsSrc from '@kbn/ui-shared-deps-src';
|
||||
|
||||
|
@ -271,15 +270,6 @@ export function getWebpackConfig(
|
|||
IS_KIBANA_DISTRIBUTABLE: `"true"`,
|
||||
},
|
||||
}),
|
||||
new CompressionPlugin({
|
||||
algorithm: 'brotliCompress',
|
||||
filename: '[path].br',
|
||||
test: /\.(js|css)$/,
|
||||
cache: false,
|
||||
compressionOptions: {
|
||||
level: 11,
|
||||
},
|
||||
}),
|
||||
],
|
||||
|
||||
optimization: {
|
||||
|
|
|
@ -87,6 +87,7 @@ export function runCli() {
|
|||
await Tasks.initTargets(context);
|
||||
await Tasks.buildBazelPackages(context);
|
||||
await Tasks.optimize(context);
|
||||
await Tasks.brotliCompressBundles(context);
|
||||
await Tasks.writePublicAssets(context);
|
||||
await Tasks.writeServerFiles(context);
|
||||
await Tasks.yarnInstall(context);
|
||||
|
|
|
@ -86,6 +86,7 @@ it('builds a generated plugin into a viable archive', async () => {
|
|||
info running @kbn/optimizer
|
||||
│ succ browser bundle created at plugins/foo_test_plugin/build/kibana/fooTestPlugin/target/public
|
||||
│ info stopping @kbn/optimizer
|
||||
info compressing js and css bundles found at plugins/foo_test_plugin/build/kibana/fooTestPlugin/target/public to brotli
|
||||
info copying assets from \`public/assets\` to build
|
||||
info copying server source into the build and converting with babel
|
||||
info running yarn to install dependencies
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
||||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import Path from 'path';
|
||||
import { pipeline } from 'stream';
|
||||
import { promisify } from 'util';
|
||||
|
||||
import vfs from 'vinyl-fs';
|
||||
import del from 'del';
|
||||
import gulpBrotli from 'gulp-brotli';
|
||||
import zlib from 'zlib';
|
||||
import { REPO_ROOT } from '@kbn/repo-info';
|
||||
|
||||
import { TaskContext } from '../task_context';
|
||||
|
||||
const asyncPipeline = promisify(pipeline);
|
||||
|
||||
export async function brotliCompressBundles({ buildDir, log }: TaskContext) {
|
||||
const compressDir = Path.resolve(buildDir, 'target/public');
|
||||
|
||||
log.info(
|
||||
`compressing js and css bundles found at ${Path.relative(REPO_ROOT, compressDir)} to brotli`
|
||||
);
|
||||
|
||||
try {
|
||||
await del(['**/*.br'], { cwd: compressDir });
|
||||
await asyncPipeline(
|
||||
vfs.src(['**/*.{js,css}'], { cwd: compressDir }),
|
||||
gulpBrotli({
|
||||
params: {
|
||||
[zlib.constants.BROTLI_PARAM_QUALITY]: zlib.constants.BROTLI_MAX_QUALITY,
|
||||
},
|
||||
}),
|
||||
vfs.dest(compressDir)
|
||||
);
|
||||
} catch (e) {
|
||||
log.error(e);
|
||||
}
|
||||
}
|
|
@ -7,17 +7,13 @@
|
|||
*/
|
||||
|
||||
import Path from 'path';
|
||||
import { pipeline } from 'stream';
|
||||
import { promisify } from 'util';
|
||||
import Fs from 'fs';
|
||||
|
||||
import archiver from 'archiver';
|
||||
import del from 'del';
|
||||
import vfs from 'vinyl-fs';
|
||||
import zip from 'gulp-zip';
|
||||
|
||||
import { TaskContext } from '../task_context';
|
||||
|
||||
const asyncPipeline = promisify(pipeline);
|
||||
|
||||
export async function createArchive({ kibanaVersion, plugin, log }: TaskContext) {
|
||||
const {
|
||||
manifest: { id },
|
||||
|
@ -30,15 +26,14 @@ export async function createArchive({ kibanaVersion, plugin, log }: TaskContext)
|
|||
const buildDir = Path.resolve(directory, 'build');
|
||||
|
||||
// zip up the build files
|
||||
await asyncPipeline(
|
||||
vfs.src([`kibana/${id}/**/*`], {
|
||||
cwd: buildDir,
|
||||
base: buildDir,
|
||||
dot: true,
|
||||
}),
|
||||
zip(zipName),
|
||||
vfs.dest(buildDir)
|
||||
);
|
||||
const output = Fs.createWriteStream(Path.resolve(buildDir, zipName));
|
||||
const archive = archiver('zip', { zlib: { level: 9 } });
|
||||
archive.pipe(output);
|
||||
|
||||
const directoryToAdd = Path.resolve(buildDir, 'kibana');
|
||||
const directoryNameOnZip = Path.basename(directoryToAdd);
|
||||
|
||||
await archive.directory(directoryToAdd, directoryNameOnZip).finalize();
|
||||
|
||||
// delete the files that were zipped
|
||||
await del(Path.resolve(buildDir, 'kibana'));
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*/
|
||||
|
||||
export * from './bazel_packages';
|
||||
export * from './brotli_compress_bundles';
|
||||
export * from './clean';
|
||||
export * from './create_archive';
|
||||
export * from './optimize';
|
||||
|
|
44
yarn.lock
44
yarn.lock
|
@ -8810,13 +8810,6 @@
|
|||
dependencies:
|
||||
"@types/color-convert" "*"
|
||||
|
||||
"@types/compression-webpack-plugin@^2.0.2":
|
||||
version "2.0.2"
|
||||
resolved "https://registry.yarnpkg.com/@types/compression-webpack-plugin/-/compression-webpack-plugin-2.0.2.tgz#9d8956a542ea974e018ab5dc2316480edbaf17fb"
|
||||
integrity sha512-4GW0o21FHqRwP/HYC8o7ceiO9duBopo1v5MaTVZy8VqF6nnRRDoG/C6djGxAmC7uyXRBK8AdnB2IVQgkoRokXQ==
|
||||
dependencies:
|
||||
"@types/webpack" "*"
|
||||
|
||||
"@types/connect-history-api-fallback@^1.3.5":
|
||||
version "1.3.5"
|
||||
resolved "https://registry.yarnpkg.com/@types/connect-history-api-fallback/-/connect-history-api-fallback-1.3.5.tgz#d1f7a8a09d0ed5a57aee5ae9c18ab9b803205dae"
|
||||
|
@ -9075,13 +9068,6 @@
|
|||
dependencies:
|
||||
"@types/node" "*"
|
||||
|
||||
"@types/gulp-zip@^4.0.1":
|
||||
version "4.0.1"
|
||||
resolved "https://registry.yarnpkg.com/@types/gulp-zip/-/gulp-zip-4.0.1.tgz#96cd0b994219f9ae3bbbec7ec3baa043fba9d9ef"
|
||||
integrity sha512-dYwGsHmwv4pnMD+jtyuIdZchJ0CIivnl8PIApHC+rYN7FMj01tJSAiQb+YN4T/pOn10pmmucBLEB9wXEhQX2Ug==
|
||||
dependencies:
|
||||
"@types/node" "*"
|
||||
|
||||
"@types/gulp@^4.0.6":
|
||||
version "4.0.6"
|
||||
resolved "https://registry.yarnpkg.com/@types/gulp/-/gulp-4.0.6.tgz#68fe0e1f0ff3657cfca46fb564806b744a1bf899"
|
||||
|
@ -12426,7 +12412,7 @@ cacache@^12.0.2:
|
|||
unique-filename "^1.1.1"
|
||||
y18n "^4.0.0"
|
||||
|
||||
cacache@^15.0.3, cacache@^15.0.4, cacache@^15.0.5, cacache@^15.2.0:
|
||||
cacache@^15.0.4, cacache@^15.0.5, cacache@^15.2.0:
|
||||
version "15.3.0"
|
||||
resolved "https://registry.yarnpkg.com/cacache/-/cacache-15.3.0.tgz#dc85380fb2f556fe3dda4c719bfa0ec875a7f1eb"
|
||||
integrity sha512-VVdYzXEn+cnbXpFgWs5hTT7OScegHVmLhJIR8Ufqk3iFD6A6j5iSX1KuBTfNEv4tdJWE2PzA6IVFtcLC7fN9wQ==
|
||||
|
@ -13335,17 +13321,6 @@ compressible@~2.0.16:
|
|||
dependencies:
|
||||
mime-db ">= 1.40.0 < 2"
|
||||
|
||||
compression-webpack-plugin@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/compression-webpack-plugin/-/compression-webpack-plugin-4.0.0.tgz#7599f592050002a49cd3ad3ee18ae7371e266bca"
|
||||
integrity sha512-DRoFQNTkQ8gadlk117Y2wxANU+MDY56b1FIZj/yJXucBOTViTHXjthM7G9ocnitksk4kLzt1N2RLF0gDjxI+hg==
|
||||
dependencies:
|
||||
cacache "^15.0.3"
|
||||
find-cache-dir "^3.3.1"
|
||||
schema-utils "^2.6.6"
|
||||
serialize-javascript "^3.0.0"
|
||||
webpack-sources "^1.4.3"
|
||||
|
||||
compression@^1.7.4:
|
||||
version "1.7.4"
|
||||
resolved "https://registry.yarnpkg.com/compression/-/compression-1.7.4.tgz#95523eff170ca57c29a0ca41e6fe131f41e5bb8f"
|
||||
|
@ -18020,17 +17995,6 @@ gulp-terser@^2.1.0:
|
|||
through2 "^4.0.2"
|
||||
vinyl-sourcemaps-apply "^0.2.1"
|
||||
|
||||
gulp-zip@^5.0.2:
|
||||
version "5.0.2"
|
||||
resolved "https://registry.yarnpkg.com/gulp-zip/-/gulp-zip-5.0.2.tgz#2edf797ec842e770f4dfde8bef97d139015b1972"
|
||||
integrity sha512-rZd0Ppuc8Bf7J2/WzcdNaeb+lcEXf1R8mV/PJ9Kdu7PmnInWVeLSmiXIka/2QSe6uhAsGVFAMffWSaMzAPGTBg==
|
||||
dependencies:
|
||||
get-stream "^5.1.0"
|
||||
plugin-error "^1.0.1"
|
||||
through2 "^3.0.1"
|
||||
vinyl "^2.1.0"
|
||||
yazl "^2.5.1"
|
||||
|
||||
gzip-size@^6.0.0:
|
||||
version "6.0.0"
|
||||
resolved "https://registry.yarnpkg.com/gzip-size/-/gzip-size-6.0.0.tgz#065367fd50c239c0671cbcbad5be3e2eeb10e462"
|
||||
|
@ -27112,7 +27076,7 @@ scheduler@^0.20.2:
|
|||
loose-envify "^1.1.0"
|
||||
object-assign "^4.1.1"
|
||||
|
||||
schema-utils@2.7.0, schema-utils@^2.0.0, schema-utils@^2.0.1, schema-utils@^2.5.0, schema-utils@^2.6.5, schema-utils@^2.6.6, schema-utils@^2.7.0:
|
||||
schema-utils@2.7.0, schema-utils@^2.0.0, schema-utils@^2.0.1, schema-utils@^2.5.0, schema-utils@^2.6.5, schema-utils@^2.7.0:
|
||||
version "2.7.0"
|
||||
resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-2.7.0.tgz#17151f76d8eae67fbbf77960c33c676ad9f4efc7"
|
||||
integrity sha512-0ilKFI6QQF5nxDZLFn2dMjvc4hjg/Wkg7rHd3jK6/A4a1Hl9VFdQWvgB1UMGoU94pad1P/8N7fMcEnLnSiju8A==
|
||||
|
@ -27269,7 +27233,7 @@ serialize-javascript@6.0.0, serialize-javascript@^6.0.0:
|
|||
dependencies:
|
||||
randombytes "^2.1.0"
|
||||
|
||||
serialize-javascript@^3.0.0, serialize-javascript@^3.1.0:
|
||||
serialize-javascript@^3.1.0:
|
||||
version "3.1.0"
|
||||
resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-3.1.0.tgz#8bf3a9170712664ef2561b44b691eafe399214ea"
|
||||
integrity sha512-JIJT1DGiWmIKhzRsG91aS6Ze4sFUrYbltlkg2onR5OrnNM02Kl/hnY/T4FN2omvyeBbQmMJv+K4cPOpGzOTFBg==
|
||||
|
@ -30675,7 +30639,7 @@ vinyl-sourcemaps-apply@^0.2.1:
|
|||
dependencies:
|
||||
source-map "^0.5.1"
|
||||
|
||||
vinyl@^2.1.0, vinyl@^2.2.0:
|
||||
vinyl@^2.2.0:
|
||||
version "2.2.0"
|
||||
resolved "https://registry.yarnpkg.com/vinyl/-/vinyl-2.2.0.tgz#d85b07da96e458d25b2ffe19fece9f2caa13ed86"
|
||||
integrity sha512-MBH+yP0kC/GQ5GwBqrTPTzEfiiLjta7hTtvQtbxBgTeSXsmKQRQecjibMbxIXzVT3Y9KJK+drOz1/k+vsu8Nkg==
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue