mirror of
https://github.com/grafana/grafana.git
synced 2025-09-19 02:02:48 +08:00
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:
@ -8,6 +8,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');
|
||||
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
||||
|
||||
@ -51,11 +52,11 @@ module.exports = (env = {}) =>
|
||||
// https://webpack.js.org/guides/build-performance/#output-without-path-info
|
||||
output: {
|
||||
pathinfo: false,
|
||||
filename: '[name].js',
|
||||
},
|
||||
|
||||
// https://webpack.js.org/guides/build-performance/#avoid-extra-optimization-steps
|
||||
optimization: {
|
||||
moduleIds: 'named',
|
||||
runtimeChunk: true,
|
||||
removeAvailableModules: false,
|
||||
removeEmptyChunks: false,
|
||||
@ -91,7 +92,7 @@ module.exports = (env = {}) =>
|
||||
extensions: ['.ts', '.tsx'],
|
||||
}),
|
||||
new MiniCssExtractPlugin({
|
||||
filename: 'grafana.[name].[fullhash].css',
|
||||
filename: 'grafana.[name].[contenthash].css',
|
||||
}),
|
||||
new HtmlWebpackPlugin({
|
||||
filename: path.resolve(__dirname, '../../public/views/error.html'),
|
||||
@ -103,11 +104,11 @@ module.exports = (env = {}) =>
|
||||
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 DefinePlugin({
|
||||
'process.env': {
|
||||
NODE_ENV: JSON.stringify('development'),
|
||||
|
Reference in New Issue
Block a user