Build: Enable long term caching for frontend assets (#47625) (#49691)

* build(webpack): move CopyUniconsPlugin into own file

* chore(webpack): delete unused blobUrl and compile loaders

* build(webpack): prefer contenthash over fullhash for longer caching

* build(webpack): set optimization.moduleIds named only in dev

* build(webpack): introduce HTMLWebpackCSSChunks so templates can access theme css by name

* feat: inject css files with contenthash in html templates

* revert(error-template): remove ContentDeliveryURL from CSS href

* refactor(index-template): update grafanaBootData.themePaths

* chore(webpack): add typescript annotations for CopyUniconsPlugin

(cherry picked from commit 78bef7a26a)

Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>
This commit is contained in:
Grot (@grafanabot)
2022-05-26 14:43:41 +02:00
committed by GitHub
co-authored by Jack Westbrook
parent 83b73db401
commit db1c49a95b
10 changed files with 108 additions and 154 deletions
+3 -1
View File
@@ -7,6 +7,7 @@ const path = require('path');
const TerserPlugin = require('terser-webpack-plugin');
const { merge } = require('webpack-merge');
const HTMLWebpackCSSChunks = require('./plugins/HTMLWebpackCSSChunks');
const common = require('./webpack.common.js');
module.exports = (env = {}) =>
@@ -63,7 +64,7 @@ module.exports = (env = {}) =>
plugins: [
new MiniCssExtractPlugin({
filename: 'grafana.[name].[fullhash].css',
filename: 'grafana.[name].[contenthash].css',
}),
new HtmlWebpackPlugin({
filename: path.resolve(__dirname, '../../public/views/error.html'),
@@ -79,6 +80,7 @@ module.exports = (env = {}) =>
excludeChunks: ['manifest', 'dark', 'light'],
chunksSortMode: 'none',
}),
new HTMLWebpackCSSChunks(),
function () {
this.hooks.done.tap('Done', function (stats) {
if (stats.compilation.errors && stats.compilation.errors.length) {