Skip to content

Commit 90b411f

Browse files
authored
Fix missing icon assets (#2985)
* Serve Grafana icons via CDN * Improve comment * Improve Grafana assets CDN url * Bundle icons from @grafana/ui * Reformat with prettier
1 parent 369ca83 commit 90b411f

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

public/app/app.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@ const root = ReactDOM.createRoot(container);
2323

2424
setupReduxQuerySync();
2525

26+
declare global {
27+
interface Window {
28+
__grafana_public_path__: string;
29+
}
30+
}
31+
32+
if (typeof window !== 'undefined') {
33+
// Icons from @grafana/ui are not bundled, this forces them to be loaded via a CDN instead.
34+
window.__grafana_public_path__ = 'assets/grafana/';
35+
}
36+
2637
function App() {
2738
useSelectFirstApp();
2839

scripts/webpack/webpack.common.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
1-
const HtmlWebpackPlugin = require('html-webpack-plugin');
1+
const CopyWebpackPlugin = require('copy-webpack-plugin');
2+
23
const path = require('path');
34
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
4-
//const { dependencies: pyroOSSDeps } = require('../../og/package.json');
5-
const webpack = require('webpack');
6-
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
7-
8-
// this is so that we don't import dependencies twice, once from pyroscope-oss and another from here
9-
// const deps = Object.entries(pyroOSSDeps).reduce((prev, [name]) => {
10-
// return {
11-
// ...prev,
12-
// [name]: path.resolve(__dirname, `../../node_modules/${name}`),
13-
// };
14-
// }, {});
155

166
module.exports = {
177
target: 'web',
@@ -58,6 +48,14 @@ module.exports = {
5848
new MiniCssExtractPlugin({
5949
filename: '[name].[contenthash].css',
6050
}),
51+
new CopyWebpackPlugin({
52+
patterns: [
53+
{
54+
from: 'node_modules/@grafana/ui/dist/public/img/icons',
55+
to: 'grafana/img/icons/',
56+
},
57+
],
58+
}),
6159
],
6260
module: {
6361
rules: [

scripts/webpack/webpack.dev.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ module.exports = merge(common, {
1313
proxy: {
1414
'/pyroscope': 'http://localhost:4040',
1515
'/querier.v1.QuerierService': 'http://localhost:4040',
16+
'/assets/grafana/*': {
17+
target: 'http://localhost:4041',
18+
pathRewrite: { '^/assets': '' },
19+
logLevel: 'debug',
20+
},
1621
},
1722
},
1823
optimization: {

0 commit comments

Comments
 (0)