| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- import nodeResolve from '@rollup/plugin-node-resolve';
- import commonjs from '@rollup/plugin-commonjs';
- import babel from '@rollup/plugin-babel';
- import replace from '@rollup/plugin-replace';
- import terser from '@rollup/plugin-terser';
- import license from 'rollup-plugin-license';
- import path from 'path';
- import { fileURLToPath } from 'url';
- import { dirname } from 'path';
- const __filename = fileURLToPath(import.meta.url);
- const __dirname = dirname(__filename);
- const VERSION = process.env.VERSION || 'snapshot'; // default snapshot
- const FILE = process.env.FILE;
- const SOURCEMAPS = process.env.SOURCEMAPS === 'true'; // default false
- const BABEL = process.env.BABEL !== 'false'; // default true
- const NODE_ENV = process.env.NODE_ENV === 'development' ? 'development' : 'production'; // default prod
- const input = './src/index.mjs';
- const name = 'cytoscape';
- const envVariables = {
- 'process.env.VERSION': JSON.stringify(VERSION),
- 'process.env.NODE_ENV': JSON.stringify(NODE_ENV)
- };
- const replaceOptions = {
- values: envVariables,
- preventAssignment: true
- };
- const getBabelOptions = () => ({
- exclude: '**/node_modules/**',
- babelHelpers: 'bundled'
- });
- // Ignore all node_modules dependencies
- const isExternal = id => !id.startsWith('\0') && !id.startsWith('.') && !id.startsWith('/');
- const licenseHeaderOptions = {
- sourcemap: true,
- banner: {
- content: {
- file: path.join(__dirname, 'LICENSE')
- }
- }
- };
- const configs = [
- {
- input,
- output: {
- file: 'build/cytoscape.umd.js',
- format: 'umd',
- name,
- sourcemap: SOURCEMAPS ? 'inline' : false
- },
- plugins: [
- nodeResolve(),
- commonjs({ include: '**/node_modules/**' }),
- BABEL ? babel(getBabelOptions()) : {},
- replace(replaceOptions),
- license(licenseHeaderOptions)
- ]
- },
- {
- input,
- output: {
- file: 'build/cytoscape.min.js',
- format: 'umd',
- name
- },
- plugins: [
- nodeResolve(),
- commonjs({ include: '**/node_modules/**' }),
- BABEL ? babel(getBabelOptions()) : {},
- replace(replaceOptions),
- terser(),
- license(licenseHeaderOptions)
- ]
- },
- {
- input,
- output: {
- file: 'build/cytoscape.esm.min.mjs',
- format: 'es'
- },
- plugins: [
- nodeResolve(),
- commonjs({ include: '**/node_modules/**' }),
- BABEL ? babel(getBabelOptions()) : {},
- replace(replaceOptions),
- license(licenseHeaderOptions),
- terser()
- ]
- },
- {
- input,
- output: { file: 'build/cytoscape.cjs.js', format: 'cjs' },
- plugins: [
- nodeResolve(),
- commonjs({ include: '**/node_modules/**' }),
- BABEL ? babel(getBabelOptions()) : {},
- replace(replaceOptions),
- license(licenseHeaderOptions)
- ]
- },
- {
- input,
- output: { file: 'build/cytoscape.esm.mjs', format: 'es' },
- plugins: [
- nodeResolve(),
- commonjs({ include: '**/node_modules/**' }),
- BABEL ? babel(getBabelOptions()) : {},
- replace(replaceOptions),
- license(licenseHeaderOptions)
- ]
- }
- ];
- export default FILE
- ? configs.filter(config => config.output.file.endsWith(FILE + '.js') || config.output.file.endsWith(FILE + '.mjs'))
- : configs;
|