summaryrefslogtreecommitdiffstats
path: root/webpack.config.js
diff options
context:
space:
mode:
authorsilverwind <me@silverwind.io>2022-08-23 14:58:04 +0200
committerGitHub <noreply@github.com>2022-08-23 20:58:04 +0800
commit56220515fc882943e366fafbce4d5b2b3ccee702 (patch)
treed64bffc3a9d13ce01bf56aedc896923aa4af0acf /webpack.config.js
parent0a9ed54abbe8b6837dcb22a35b744c11f410421f (diff)
downloadgitea-56220515fc882943e366fafbce4d5b2b3ccee702.tar.gz
gitea-56220515fc882943e366fafbce4d5b2b3ccee702.zip
Enable contenthash in filename for dynamic assets (#20813)
This should solve the main problem of dynamic assets getting stale after a version upgrade. Everything not affected will use query-string based cache busting, which includes files loaded via HTML or worker scripts.
Diffstat (limited to 'webpack.config.js')
-rw-r--r--webpack.config.js12
1 files changed, 6 insertions, 6 deletions
diff --git a/webpack.config.js b/webpack.config.js
index 5109103f7f..9252a5a31f 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -74,7 +74,7 @@ export default {
},
chunkFilename: ({chunk}) => {
const language = (/monaco.*languages?_.+?_(.+?)_/.exec(chunk.id) || [])[1];
- return language ? `js/monaco-language-${language.toLowerCase()}.js` : `js/[name].js`;
+ return `js/${language ? `monaco-language-${language.toLowerCase()}` : `[name]`}.[contenthash:8].js`;
},
},
optimization: {
@@ -173,14 +173,14 @@ export default {
test: /\.(ttf|woff2?)$/,
type: 'asset/resource',
generator: {
- filename: 'fonts/[name][ext]',
+ filename: 'fonts/[name].[contenthash:8][ext]',
}
},
{
test: /\.png$/i,
type: 'asset/resource',
generator: {
- filename: 'img/webpack/[name][ext]',
+ filename: 'img/webpack/[name].[contenthash:8][ext]',
}
},
],
@@ -189,17 +189,17 @@ export default {
new VueLoaderPlugin(),
new MiniCssExtractPlugin({
filename: 'css/[name].css',
- chunkFilename: 'css/[name].css',
+ chunkFilename: 'css/[name].[contenthash:8].css',
}),
new SourceMapDevToolPlugin({
- filename: '[file].map',
+ filename: '[file].[contenthash:8].map',
include: [
'js/index.js',
'css/index.css',
],
}),
new MonacoWebpackPlugin({
- filename: 'js/monaco-[name].worker.js',
+ filename: 'js/monaco-[name].[contenthash:8].worker.js',
}),
isProduction ? new LicenseCheckerWebpackPlugin({
outputFilename: 'js/licenses.txt',