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:
Huan Wang
2019-10-15 08:03:35 -06:00
committed by Dominik Prokop
parent d0d59b8001
commit 7da2156237
2 changed files with 21 additions and 0 deletions

View 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;
};

View File

@@ -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]',
},
},
];
};