mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
|
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;
|