import { babel } from '@rollup/plugin-babel'
import css from 'rollup-plugin-import-css'
import globals from 'rollup-plugin-node-globals'
import terser from '@rollup/plugin-terser'
import json from '@rollup/plugin-json'
import commonjs from '@rollup/plugin-commonjs'
import resolve from '@rollup/plugin-node-resolve'
import nodePolyfills from 'rollup-plugin-polyfill-node'
import { uglify } from 'rollup-plugin-uglify'

// import copy from 'rollup-plugin-copy'

export default {
  input: 'src/index.js',
  output: [
    {
      format: 'umd',
      file: 'dist/lib/bundle.cjs.js',
      name: 'bundlename'
      // globals: {
      //     'three': 'three',
      //     'rxjs': 'rxjs',
      //     "@tslfe/dt-engine": "DTEngine"
      // }
    },
    {
      format: 'es',
      file: 'dist/lib/mapadapter-2.0.18.esm.js',
      name: 'bundlename'
      // globals: {
      //     'rxjs': 'rxjs',
      //     'three': 'three',
      //     "@tslfe/dt-engine": "DTEngine"
      // }
    },
    {
      format: 'iife',
      file: 'dist/lib/mapadapter-2.0.18.js',
      name: 'mapadapter'
    }
  ],
  plugins: [
    resolve(),
    commonjs(),
    babel({
      exclude: 'node_modules/**',
      babelHelpers: 'bundled'
    }),
    css(),
    globals(),
    terser(),
    json(),
    nodePolyfills(),
    // copy({
    //     targets: [
    //         { src: 'common', dest: 'public' }
    //     ]
    // }),
    uglify()
  ]
  // external: ['rxjs', 'three', '@tslfe/dt-engine']
  // external: [ '@tslfe/dt-engine']
  // external: [ 'three']
}
