2020-03-15 16:39:40 +01:00
|
|
|
import commonjs from '@rollup/plugin-commonjs';
|
2022-04-22 14:33:13 +01:00
|
|
|
import resolve from '@rollup/plugin-node-resolve';
|
2022-04-14 08:49:56 -06:00
|
|
|
import svg from 'rollup-plugin-svg-import';
|
2019-02-21 10:58:28 +01:00
|
|
|
import { terser } from 'rollup-plugin-terser';
|
|
|
|
|
|
|
|
const pkg = require('./package.json');
|
|
|
|
|
|
|
|
const libraryName = pkg.name;
|
|
|
|
|
|
|
|
const buildCjsPackage = ({ env }) => {
|
|
|
|
return {
|
|
|
|
input: `compiled/index.js`,
|
|
|
|
output: [
|
|
|
|
{
|
2020-06-30 09:22:09 +02:00
|
|
|
dir: 'dist',
|
2019-02-21 10:58:28 +01:00
|
|
|
name: libraryName,
|
|
|
|
format: 'cjs',
|
|
|
|
sourcemap: true,
|
2020-01-03 10:02:27 +01:00
|
|
|
strict: false,
|
2019-02-21 10:58:28 +01:00
|
|
|
exports: 'named',
|
2020-06-30 09:22:09 +02:00
|
|
|
chunkFileNames: `[name].${env}.js`,
|
2019-02-21 10:58:28 +01:00
|
|
|
globals: {
|
|
|
|
react: 'React',
|
|
|
|
'prop-types': 'PropTypes',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
2020-06-29 10:58:47 -07:00
|
|
|
external: [
|
|
|
|
'react',
|
|
|
|
'react-dom',
|
2021-03-30 12:30:34 +02:00
|
|
|
'@grafana/aws-sdk',
|
2020-06-29 10:58:47 -07:00
|
|
|
'@grafana/data',
|
2021-08-23 13:03:41 -07:00
|
|
|
'@grafana/schema',
|
2020-06-29 10:58:47 -07:00
|
|
|
'@grafana/e2e-selectors',
|
|
|
|
'moment',
|
2020-09-22 16:43:57 +08:00
|
|
|
'jquery', // required to use jquery.plot, which is assigned externally
|
2021-10-01 15:07:22 +02:00
|
|
|
'react-inlinesvg', // required to mock Icon svg loading in tests
|
2022-05-05 10:06:21 +02:00
|
|
|
'@emotion/react',
|
|
|
|
'@emotion/css',
|
2020-06-29 10:58:47 -07:00
|
|
|
],
|
2019-02-21 10:58:28 +01:00
|
|
|
plugins: [
|
|
|
|
commonjs({
|
|
|
|
include: /node_modules/,
|
2022-05-05 10:06:21 +02:00
|
|
|
ignoreTryCatch: false,
|
2019-02-21 10:58:28 +01:00
|
|
|
}),
|
|
|
|
resolve(),
|
2022-04-14 08:49:56 -06:00
|
|
|
svg({ stringify: true }),
|
2019-02-21 10:58:28 +01:00
|
|
|
env === 'production' && terser(),
|
|
|
|
],
|
|
|
|
};
|
|
|
|
};
|
|
|
|
export default [buildCjsPackage({ env: 'development' }), buildCjsPackage({ env: 'production' })];
|