2019-02-21 03:58:28 -06:00
|
|
|
import resolve from 'rollup-plugin-node-resolve';
|
|
|
|
import commonjs from 'rollup-plugin-commonjs';
|
2019-09-23 06:26:05 -05:00
|
|
|
// import sourceMaps from 'rollup-plugin-sourcemaps';
|
2019-02-21 03:58:28 -06: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: [
|
|
|
|
{
|
|
|
|
file: `dist/index.${env}.js`,
|
|
|
|
name: libraryName,
|
|
|
|
format: 'cjs',
|
|
|
|
sourcemap: true,
|
|
|
|
exports: 'named',
|
|
|
|
globals: {
|
|
|
|
react: 'React',
|
|
|
|
'prop-types': 'PropTypes',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
2019-06-25 07:13:39 -05:00
|
|
|
external: ['react', 'react-dom', '@grafana/data'],
|
2019-02-21 03:58:28 -06:00
|
|
|
plugins: [
|
|
|
|
commonjs({
|
|
|
|
include: /node_modules/,
|
2019-06-26 00:35:58 -05:00
|
|
|
// When 'rollup-plugin-commonjs' fails to properly convert the CommonJS modules to ES6 one has to manually name the exports
|
|
|
|
// https://github.com/rollup/rollup-plugin-commonjs#custom-named-exports
|
2019-02-21 03:58:28 -06:00
|
|
|
namedExports: {
|
|
|
|
'../../node_modules/lodash/lodash.js': [
|
|
|
|
'flatten',
|
|
|
|
'find',
|
|
|
|
'upperFirst',
|
|
|
|
'debounce',
|
|
|
|
'isNil',
|
|
|
|
'isNumber',
|
|
|
|
'flattenDeep',
|
|
|
|
'map',
|
|
|
|
'chunk',
|
|
|
|
'sortBy',
|
|
|
|
'uniqueId',
|
|
|
|
'zip',
|
2019-05-07 02:07:54 -05:00
|
|
|
'omit',
|
2019-02-21 03:58:28 -06:00
|
|
|
],
|
|
|
|
'../../node_modules/react-color/lib/components/common': ['Saturation', 'Hue', 'Alpha'],
|
2019-06-25 07:13:39 -05:00
|
|
|
'../../node_modules/immutable/dist/immutable.js': [
|
2019-09-23 06:26:05 -05:00
|
|
|
'Record',
|
2019-06-25 07:13:39 -05:00
|
|
|
'Set',
|
|
|
|
'Map',
|
|
|
|
'List',
|
|
|
|
'OrderedSet',
|
|
|
|
'is',
|
|
|
|
'Stack',
|
|
|
|
],
|
2019-09-23 06:26:05 -05:00
|
|
|
'node_modules/immutable/dist/immutable.js': ['Record', 'Set', 'Map', 'List', 'OrderedSet', 'is', 'Stack'],
|
2019-06-25 07:13:39 -05:00
|
|
|
'../../node_modules/esrever/esrever.js': ['reverse'],
|
2019-10-04 05:01:42 -05:00
|
|
|
'../../node_modules/bizcharts/es6/index.js': ['Chart', 'Geom', 'View', 'Tooltip', 'Legend'],
|
2019-02-21 03:58:28 -06:00
|
|
|
},
|
|
|
|
}),
|
|
|
|
resolve(),
|
2019-09-23 06:26:05 -05:00
|
|
|
// sourceMaps(),
|
2019-02-21 03:58:28 -06:00
|
|
|
env === 'production' && terser(),
|
|
|
|
],
|
|
|
|
};
|
|
|
|
};
|
|
|
|
export default [buildCjsPackage({ env: 'development' }), buildCjsPackage({ env: 'production' })];
|