grafana/packages/grafana-ui/rollup.config.ts
Jack Westbrook cc7f7e30e9
Plugins: Mock Icon component to prevent console errors (#39901)
* feat(grafana-ui): externalise react-inlinesvg for mocking

* feat(grafana-toolkit): mock react-inlinesvg to prevent svg fetch errors in tests

* test(toolkit): remove assertion on array length of moduleNameMapper overrides

* feat(toolkit): set testId to match the Icon name prop in react-inlinesvg mock
2021-10-01 15:07:22 +02:00

50 lines
1.2 KiB
TypeScript

import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import image from '@rollup/plugin-image';
import { terser } from 'rollup-plugin-terser';
const pkg = require('./package.json');
const libraryName = pkg.name;
const buildCjsPackage = ({ env }) => {
return {
input: `compiled/index.js`,
output: [
{
dir: 'dist',
name: libraryName,
format: 'cjs',
sourcemap: true,
strict: false,
exports: 'named',
chunkFileNames: `[name].${env}.js`,
globals: {
react: 'React',
'prop-types': 'PropTypes',
},
},
],
external: [
'react',
'react-dom',
'@grafana/aws-sdk',
'@grafana/data',
'@grafana/schema',
'@grafana/e2e-selectors',
'moment',
'jquery', // required to use jquery.plot, which is assigned externally
'react-inlinesvg', // required to mock Icon svg loading in tests
],
plugins: [
commonjs({
include: /node_modules/,
}),
resolve(),
image(),
env === 'production' && terser(),
],
};
};
export default [buildCjsPackage({ env: 'development' }), buildCjsPackage({ env: 'production' })];