mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
grafana/toolkit: Add font file loader (#19781)
* add file loader for fonts * Add public path to resolve fonts correctly * Do not specify font's output path * Output fonts to fonts directory
This commit is contained in:
committed by
Dominik Prokop
parent
d0d59b8001
commit
7da2156237
11
packages/grafana-toolkit/src/config/utils/getPluginId.ts
Normal file
11
packages/grafana-toolkit/src/config/utils/getPluginId.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import path from 'path';
|
||||
|
||||
let PLUGIN_ID: string;
|
||||
|
||||
export const getPluginId = () => {
|
||||
if (!PLUGIN_ID) {
|
||||
const pluginJson = require(path.resolve(process.cwd(), 'src/plugin.json'));
|
||||
PLUGIN_ID = pluginJson.id;
|
||||
}
|
||||
return PLUGIN_ID;
|
||||
};
|
||||
@@ -1,5 +1,6 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { getPluginId } from '../utils/getPluginId';
|
||||
|
||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
||||
|
||||
@@ -139,5 +140,14 @@ export const getFileLoaders = () => {
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /\.(woff|woff2|eot|ttf|otf)(\?v=\d+\.\d+\.\d+)?$/,
|
||||
loader: 'file-loader',
|
||||
options: {
|
||||
publicPath: `/public/plugins/${getPluginId()}/fonts`,
|
||||
outputPath: 'fonts',
|
||||
name: '[name].[ext]',
|
||||
},
|
||||
},
|
||||
];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user