From 5ea01dc9b9c4fdb3c322bdb89ebad91a54304c7a Mon Sep 17 00:00:00 2001 From: Jack Westbrook Date: Tue, 30 Aug 2022 11:18:55 +0200 Subject: [PATCH] Build: Introduce webpack manifest plugin (#49798) * build(webpack): introduce manifest plugin * build(webpack): move manifest.json to root of project and git ignore --- .gitignore | 3 +++ package.json | 1 + scripts/webpack/webpack.prod.js | 5 +++++ yarn.lock | 25 ++++++++++++++++++++++++- 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 7e8c454d544..c1fc13b8bde 100644 --- a/.gitignore +++ b/.gitignore @@ -129,6 +129,9 @@ pkg/cmd/grafana-server/__debug_bin ## CI places the packages in a different location /npm-artifacts/*.tgz +# Ignore frontend build manifest +manifest.json + # Ignore go local build dependencies /scripts/go/bin/** diff --git a/package.json b/package.json index bb5a47f354e..5519ef96fc9 100644 --- a/package.json +++ b/package.json @@ -243,6 +243,7 @@ "webpack-bundle-analyzer": "4.5.0", "webpack-cli": "4.10.0", "webpack-dev-server": "4.9.3", + "webpack-manifest-plugin": "5.0.0", "webpack-merge": "5.8.0" }, "dependencies": { diff --git a/scripts/webpack/webpack.prod.js b/scripts/webpack/webpack.prod.js index 310029024b6..909962cc8a1 100644 --- a/scripts/webpack/webpack.prod.js +++ b/scripts/webpack/webpack.prod.js @@ -5,6 +5,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const path = require('path'); const TerserPlugin = require('terser-webpack-plugin'); +const { WebpackManifestPlugin } = require('webpack-manifest-plugin'); const { merge } = require('webpack-merge'); const HTMLWebpackCSSChunks = require('./plugins/HTMLWebpackCSSChunks'); @@ -81,6 +82,10 @@ module.exports = (env = {}) => chunksSortMode: 'none', }), new HTMLWebpackCSSChunks(), + new WebpackManifestPlugin({ + fileName: path.join(process.cwd(), 'manifest.json'), + filter: (file) => !file.name.endsWith('.map'), + }), function () { this.hooks.done.tap('Done', function (stats) { if (stats.compilation.errors && stats.compilation.errors.length) { diff --git a/yarn.lock b/yarn.lock index 4700333e6cc..953bbf20a93 100644 --- a/yarn.lock +++ b/yarn.lock @@ -22056,6 +22056,7 @@ __metadata: webpack-bundle-analyzer: 4.5.0 webpack-cli: 4.10.0 webpack-dev-server: 4.9.3 + webpack-manifest-plugin: 5.0.0 webpack-merge: 5.8.0 whatwg-fetch: 3.6.2 languageName: unknown @@ -34722,7 +34723,7 @@ __metadata: languageName: node linkType: hard -"source-list-map@npm:^2.0.0": +"source-list-map@npm:^2.0.0, source-list-map@npm:^2.0.1": version: 2.0.1 resolution: "source-list-map@npm:2.0.1" checksum: 806efc6f75e7cd31e4815e7a3aaf75a45c704871ea4075cb2eb49882c6fca28998f44fc5ac91adb6de03b2882ee6fb02f951fdc85e6a22b338c32bfe19557938 @@ -37973,6 +37974,18 @@ __metadata: languageName: node linkType: hard +"webpack-manifest-plugin@npm:5.0.0": + version: 5.0.0 + resolution: "webpack-manifest-plugin@npm:5.0.0" + dependencies: + tapable: ^2.0.0 + webpack-sources: ^2.2.0 + peerDependencies: + webpack: ^5.47.0 + checksum: 864d68f90870e194074756e71caf3df36b777d687a50286ba27eb1958480642b125c2cf47a2787beac52eba4b1ccf1fe8141f017c81f1e87e953481f852a7c48 + languageName: node + linkType: hard + "webpack-merge@npm:5.8.0, webpack-merge@npm:^5.7.3": version: 5.8.0 resolution: "webpack-merge@npm:5.8.0" @@ -37993,6 +38006,16 @@ __metadata: languageName: node linkType: hard +"webpack-sources@npm:^2.2.0": + version: 2.3.1 + resolution: "webpack-sources@npm:2.3.1" + dependencies: + source-list-map: ^2.0.1 + source-map: ^0.6.1 + checksum: 6fd67f2274a84c5f51ad89767112ec8b47727134bf0f2ba0cff458c970f18966939a24128bdbddba621cd66eeb2bef0552642a9333cd8e54514f7b2a71776346 + languageName: node + linkType: hard + "webpack-sources@npm:^3.2.3": version: 3.2.3 resolution: "webpack-sources@npm:3.2.3"