2020-03-15 10:39:40 -05:00
|
|
|
import commonjs from '@rollup/plugin-commonjs';
|
2020-04-27 10:20:15 -05:00
|
|
|
import json from '@rollup/plugin-json';
|
2022-04-22 08:33:13 -05:00
|
|
|
import resolve from '@rollup/plugin-node-resolve';
|
2021-10-27 08:21:07 -05:00
|
|
|
import path from 'path';
|
2022-04-22 08:33:13 -05:00
|
|
|
import sourceMaps from 'rollup-plugin-sourcemaps';
|
|
|
|
import { terser } from 'rollup-plugin-terser';
|
2019-06-18 10:17:27 -05:00
|
|
|
|
|
|
|
const pkg = require('./package.json');
|
|
|
|
|
|
|
|
const libraryName = pkg.name;
|
|
|
|
|
|
|
|
const buildCjsPackage = ({ env }) => {
|
|
|
|
return {
|
|
|
|
input: `compiled/index.js`,
|
|
|
|
output: [
|
|
|
|
{
|
|
|
|
file: `dist/index.${env}.js`,
|
|
|
|
name: libraryName,
|
|
|
|
format: 'cjs',
|
|
|
|
sourcemap: true,
|
|
|
|
exports: 'named',
|
|
|
|
globals: {},
|
|
|
|
},
|
|
|
|
],
|
2021-08-23 15:03:41 -05:00
|
|
|
external: [
|
|
|
|
'lodash',
|
|
|
|
'rxjs',
|
|
|
|
'@grafana/schema', // Load from host
|
|
|
|
],
|
2019-06-18 10:17:27 -05:00
|
|
|
plugins: [
|
2021-10-27 08:21:07 -05:00
|
|
|
resolve(),
|
2020-04-27 10:20:15 -05:00
|
|
|
json({
|
2021-10-27 08:21:07 -05:00
|
|
|
include: [path.relative('.', require.resolve('moment-timezone/data/packed/latest.json'))], // absolute path throws an error for whatever reason
|
2020-04-27 10:20:15 -05:00
|
|
|
}),
|
2019-06-18 10:17:27 -05:00
|
|
|
commonjs({
|
|
|
|
include: /node_modules/,
|
|
|
|
}),
|
|
|
|
resolve(),
|
|
|
|
sourceMaps(),
|
|
|
|
env === 'production' && terser(),
|
|
|
|
],
|
|
|
|
};
|
|
|
|
};
|
|
|
|
export default [buildCjsPackage({ env: 'development' }), buildCjsPackage({ env: 'production' })];
|