mirror of
https://github.com/grafana/grafana.git
synced 2025-09-22 00:02:53 +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:
39
scripts/webpack/plugins/CopyUniconsPlugin.js
Normal file
39
scripts/webpack/plugins/CopyUniconsPlugin.js
Normal file
@ -0,0 +1,39 @@
|
||||
const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
|
||||
class CopyUniconsPlugin {
|
||||
/**
|
||||
* @param {import('webpack').Compiler} compiler
|
||||
*/
|
||||
apply(compiler) {
|
||||
compiler.hooks.afterEnvironment.tap(
|
||||
'CopyUniconsPlugin',
|
||||
/**
|
||||
* @param {import('webpack').Compilation} compilation
|
||||
*/
|
||||
() => {
|
||||
let destDir = path.resolve(__dirname, '../../../public/img/icons/unicons');
|
||||
|
||||
if (!fs.pathExistsSync(destDir)) {
|
||||
let srcDir = path.join(
|
||||
path.dirname(require.resolve('iconscout-unicons-tarball/package.json')),
|
||||
'unicons/svg/line'
|
||||
);
|
||||
fs.copySync(srcDir, destDir);
|
||||
}
|
||||
|
||||
let solidDestDir = path.resolve(__dirname, '../../../public/img/icons/solid');
|
||||
|
||||
if (!fs.pathExistsSync(solidDestDir)) {
|
||||
let srcDir = path.join(
|
||||
path.dirname(require.resolve('iconscout-unicons-tarball/package.json')),
|
||||
'unicons/svg/solid'
|
||||
);
|
||||
fs.copySync(srcDir, solidDestDir);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = CopyUniconsPlugin;
|
Reference in New Issue
Block a user