2019-12-19 11:37:48 +01:00
|
|
|
import { terser } from 'rollup-plugin-terser'
|
|
|
|
import { resolve } from 'path'
|
2019-12-22 16:38:10 +01:00
|
|
|
import ts from '@wessberg/rollup-plugin-ts'
|
2019-12-19 11:37:48 +01:00
|
|
|
|
|
|
|
const outputDirectory = resolve(__dirname, 'dist')
|
|
|
|
const inputFile = resolve(__dirname, 'src/index.ts')
|
|
|
|
|
|
|
|
const npmConfig = require(resolve(__dirname, `package.json`))
|
|
|
|
|
|
|
|
const external = Object.keys(npmConfig.dependencies || {})
|
|
|
|
const dev = Boolean(process.env.ROLLUP_WATCH)
|
|
|
|
|
|
|
|
export default [
|
|
|
|
{
|
|
|
|
input: inputFile,
|
|
|
|
external,
|
|
|
|
output: [
|
|
|
|
{
|
2019-12-22 16:38:10 +01:00
|
|
|
file: `${outputDirectory}/index.cjs.js`,
|
2019-12-19 11:37:48 +01:00
|
|
|
format: 'cjs',
|
|
|
|
sourcemap: true
|
|
|
|
},
|
|
|
|
{
|
2019-12-22 16:38:10 +01:00
|
|
|
file: `${outputDirectory}/index.amd.js`,
|
2019-12-19 11:37:48 +01:00
|
|
|
sourcemap: true,
|
|
|
|
format: 'amd',
|
2019-12-19 13:04:54 +01:00
|
|
|
name: 'Option'
|
2019-12-19 11:37:48 +01:00
|
|
|
}
|
|
|
|
],
|
2019-12-22 16:38:10 +01:00
|
|
|
plugins: [ts(), !dev && terser()]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
input: inputFile,
|
|
|
|
external,
|
|
|
|
output: [
|
|
|
|
{
|
|
|
|
file: `${outputDirectory}/index.esm.js`,
|
|
|
|
format: 'esm',
|
|
|
|
sourcemap: true
|
|
|
|
}
|
|
|
|
],
|
2019-12-19 11:37:48 +01:00
|
|
|
plugins: [
|
2019-12-22 16:38:10 +01:00
|
|
|
ts({
|
|
|
|
tsconfig: {
|
2019-12-25 15:33:05 +01:00
|
|
|
declaration: true,
|
|
|
|
...require(resolve(__dirname, 'tsconfig.json'))[
|
|
|
|
'compilerOptions'
|
|
|
|
]
|
2019-12-22 16:38:10 +01:00
|
|
|
}
|
2019-12-19 11:37:48 +01:00
|
|
|
}),
|
|
|
|
!dev && terser()
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|