grafana/packages/grafana-ui/rollup.config.ts
Javier López 3372cb7897
make @grafana/ui run properly in SSR environments (#46288)
* allow SSR

* fix rollup commonjs default flag changed breaking in SSR

* revert wrong change

* avoid using dynamic imports

* fix test

* allow icon load in packaged version

* fix SelectBase to run on SSR

* add extra check for fixing tests

* revert wrong change

* allow SSR

* revert wrong change

* don't include emotion in the bundle

* fix wrong merge changes

* remove unneeded icon change

* use forked version of uplot

* remove unneeded bundle exceptions

* fix typescript issues

* update to latest uplot
2022-05-05 10:06:21 +02:00

53 lines
1.3 KiB
TypeScript

import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import svg from 'rollup-plugin-svg-import';
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
'@emotion/react',
'@emotion/css',
],
plugins: [
commonjs({
include: /node_modules/,
ignoreTryCatch: false,
}),
resolve(),
svg({ stringify: true }),
env === 'production' && terser(),
],
};
};
export default [buildCjsPackage({ env: 'development' }), buildCjsPackage({ env: 'production' })];