mirror of https://github.com/FreeTubeApp/FreeTube
Include swiper version in CSS file name, for cache busting (#4685)
This commit is contained in:
parent
cfaec7eaa2
commit
161633d1d9
|
@ -11,6 +11,8 @@ const CopyWebpackPlugin = require('copy-webpack-plugin')
|
|||
|
||||
const isDevMode = process.env.NODE_ENV === 'development'
|
||||
|
||||
const { version: swiperVersion } = JSON.parse(readFileSync(path.join(__dirname, '../node_modules/swiper/package.json')))
|
||||
|
||||
const processLocalesPlugin = new ProcessLocalesPlugin({
|
||||
compress: !isDevMode,
|
||||
inputDir: path.join(__dirname, '../static/locales'),
|
||||
|
@ -118,7 +120,8 @@ const config = {
|
|||
'process.env.IS_ELECTRON': true,
|
||||
'process.env.IS_ELECTRON_MAIN': false,
|
||||
'process.env.LOCALE_NAMES': JSON.stringify(processLocalesPlugin.localeNames),
|
||||
'process.env.GEOLOCATION_NAMES': JSON.stringify(readdirSync(path.join(__dirname, '..', 'static', 'geolocations')).map(filename => filename.replace('.json', '')))
|
||||
'process.env.GEOLOCATION_NAMES': JSON.stringify(readdirSync(path.join(__dirname, '..', 'static', 'geolocations')).map(filename => filename.replace('.json', ''))),
|
||||
'process.env.SWIPER_VERSION': `'${swiperVersion}'`
|
||||
}),
|
||||
new HtmlWebpackPlugin({
|
||||
excludeChunks: ['processTaskWorker'],
|
||||
|
@ -137,7 +140,7 @@ const config = {
|
|||
patterns: [
|
||||
{
|
||||
from: path.join(__dirname, '../node_modules/swiper/modules/{a11y,navigation,pagination}-element.css').replaceAll('\\', '/'),
|
||||
to: 'swiper.css',
|
||||
to: `swiper-${swiperVersion}.css`,
|
||||
context: path.join(__dirname, '../node_modules/swiper/modules'),
|
||||
transformAll: (assets) => {
|
||||
return Buffer.concat(assets.map(asset => asset.data))
|
||||
|
|
|
@ -11,6 +11,8 @@ const ProcessLocalesPlugin = require('./ProcessLocalesPlugin')
|
|||
|
||||
const isDevMode = process.env.NODE_ENV === 'development'
|
||||
|
||||
const { version: swiperVersion } = JSON.parse(fs.readFileSync(path.join(__dirname, '../node_modules/swiper/package.json')))
|
||||
|
||||
const config = {
|
||||
name: 'web',
|
||||
mode: process.env.NODE_ENV,
|
||||
|
@ -114,6 +116,7 @@ const config = {
|
|||
new webpack.DefinePlugin({
|
||||
'process.env.IS_ELECTRON': false,
|
||||
'process.env.IS_ELECTRON_MAIN': false,
|
||||
'process.env.SWIPER_VERSION': `'${swiperVersion}'`,
|
||||
|
||||
// video.js' vhs-utils supports both atob() in web browsers and Buffer in node
|
||||
// As the FreeTube web build only runs in web browsers, we can override their check for atob() here: https://github.com/videojs/vhs-utils/blob/main/src/decode-b64-to-uint8-array.js#L3
|
||||
|
@ -145,7 +148,7 @@ const config = {
|
|||
patterns: [
|
||||
{
|
||||
from: path.join(__dirname, '../node_modules/swiper/modules/{a11y,navigation,pagination}-element.css').replaceAll('\\', '/'),
|
||||
to: 'swiper.css',
|
||||
to: `swiper-${swiperVersion}.css`,
|
||||
context: path.join(__dirname, '../node_modules/swiper/modules'),
|
||||
transformAll: (assets) => {
|
||||
return Buffer.concat(assets.map(asset => asset.data))
|
||||
|
|
|
@ -73,7 +73,7 @@ export default defineComponent({
|
|||
injectStylesUrls: [
|
||||
// This file is created with the copy webpack plugin in the web and renderer webpack configs.
|
||||
// If you add more modules, please remember to add their CSS files to the list in webpack config files.
|
||||
createWebURL('/swiper.css')
|
||||
createWebURL(`/swiper-${process.env.SWIPER_VERSION}.css`)
|
||||
],
|
||||
|
||||
a11y: true,
|
||||
|
|
Loading…
Reference in New Issue