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

* 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
This commit is contained in:
Jack Westbrook
2022-05-26 11:49:18 +02:00
committed by GitHub
parent 20a83ba14f
commit 78bef7a26a
10 changed files with 108 additions and 154 deletions
+3 -2
View File
@@ -7,6 +7,7 @@ const path = require('path');
const { DefinePlugin } = require('webpack');
const { merge } = require('webpack-merge');
const HTMLWebpackCSSChunks = require('./plugins/HTMLWebpackCSSChunks');
const common = require('./webpack.common.js');
module.exports = merge(common, {
@@ -77,16 +78,16 @@ module.exports = merge(common, {
plugins: [
new MiniCssExtractPlugin({
filename: 'grafana.[name].[fullhash].css',
filename: 'grafana.[name].[contenthash].css',
}),
new HtmlWebpackPlugin({
filename: path.resolve(__dirname, '../../public/views/index.html'),
template: path.resolve(__dirname, '../../public/views/index-template.html'),
hash: true,
inject: false,
chunksSortMode: 'none',
excludeChunks: ['dark', 'light'],
}),
new HTMLWebpackCSSChunks(),
new ReactRefreshWebpackPlugin(),
new DefinePlugin({
'process.env': {