2022-04-22 08:33:13 -05:00
|
|
|
import resolve from '@rollup/plugin-node-resolve';
|
2022-08-03 08:47:09 -05:00
|
|
|
import path from 'path';
|
2023-10-13 07:11:41 -05:00
|
|
|
import copy from 'rollup-plugin-copy';
|
2022-08-03 08:47:09 -05:00
|
|
|
import dts from 'rollup-plugin-dts';
|
|
|
|
import esbuild from 'rollup-plugin-esbuild';
|
|
|
|
import { externals } from 'rollup-plugin-node-externals';
|
2024-03-22 09:46:32 -05:00
|
|
|
import svg from 'rollup-plugin-svg-import';
|
2023-10-13 07:11:41 -05:00
|
|
|
|
|
|
|
const icons = require('../../public/app/core/icons/cached.json');
|
2019-02-21 03:58:28 -06:00
|
|
|
|
2023-02-27 06:01:24 -06:00
|
|
|
const pkg = require('./package.json');
|
2019-02-21 03:58:28 -06:00
|
|
|
|
2023-10-13 07:11:41 -05:00
|
|
|
const iconSrcPaths = icons.map((iconSubPath) => {
|
|
|
|
return `../../public/img/icons/${iconSubPath}.svg`;
|
|
|
|
});
|
|
|
|
|
2022-08-03 08:47:09 -05:00
|
|
|
export default [
|
|
|
|
{
|
|
|
|
input: 'src/index.ts',
|
2023-10-13 07:11:41 -05:00
|
|
|
plugins: [
|
|
|
|
externals({ deps: true, packagePath: './package.json' }),
|
2024-03-22 09:46:32 -05:00
|
|
|
svg({ stringify: true }),
|
2023-10-13 07:11:41 -05:00
|
|
|
resolve(),
|
|
|
|
copy({
|
|
|
|
targets: [{ src: iconSrcPaths, dest: './dist/public/' }],
|
|
|
|
flatten: false,
|
|
|
|
}),
|
|
|
|
esbuild(),
|
|
|
|
],
|
2019-02-21 03:58:28 -06:00
|
|
|
output: [
|
|
|
|
{
|
|
|
|
format: 'cjs',
|
|
|
|
sourcemap: true,
|
2022-08-03 08:47:09 -05:00
|
|
|
dir: path.dirname(pkg.publishConfig.main),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
format: 'esm',
|
|
|
|
sourcemap: true,
|
|
|
|
dir: path.dirname(pkg.publishConfig.module),
|
|
|
|
preserveModules: true,
|
2023-02-27 06:01:24 -06:00
|
|
|
// @ts-expect-error (TS cannot assure that `process.env.PROJECT_CWD` is a string)
|
|
|
|
preserveModulesRoot: path.join(process.env.PROJECT_CWD, `packages/grafana-ui/src`),
|
2019-02-21 03:58:28 -06:00
|
|
|
},
|
|
|
|
],
|
2022-08-03 08:47:09 -05:00
|
|
|
},
|
|
|
|
{
|
|
|
|
input: './compiled/index.d.ts',
|
|
|
|
plugins: [dts()],
|
|
|
|
output: {
|
|
|
|
file: pkg.publishConfig.types,
|
|
|
|
format: 'es',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
];
|