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-26 16:19:26 +01:00
|
|
|
import nodeResolve from '@rollup/plugin-node-resolve'
|
|
|
|
import commonjs from '@rollup/plugin-commonjs'
|
2019-12-26 17:13:37 +01:00
|
|
|
import _package from './package.json'
|
|
|
|
import filesize from 'rollup-plugin-filesize'
|
2019-12-19 11:37:48 +01:00
|
|
|
|
|
|
|
const inputFile = resolve(__dirname, 'src/index.ts')
|
|
|
|
|
|
|
|
const dev = Boolean(process.env.ROLLUP_WATCH)
|
|
|
|
|
2019-12-26 17:13:37 +01:00
|
|
|
const commonPlugins = [nodeResolve(), commonjs()]
|
2019-12-26 16:19:26 +01:00
|
|
|
|
2019-12-19 11:37:48 +01:00
|
|
|
export default [
|
|
|
|
{
|
|
|
|
input: inputFile,
|
|
|
|
output: [
|
|
|
|
{
|
2019-12-26 17:13:37 +01:00
|
|
|
file: _package.main,
|
2019-12-19 11:37:48 +01:00
|
|
|
format: 'cjs',
|
|
|
|
sourcemap: true
|
|
|
|
},
|
|
|
|
{
|
2019-12-26 17:13:37 +01:00
|
|
|
file: _package.browser,
|
2019-12-19 11:37:48 +01:00
|
|
|
sourcemap: true,
|
2019-12-26 17:13:37 +01:00
|
|
|
format: 'umd',
|
2019-12-19 13:04:54 +01:00
|
|
|
name: 'Option'
|
2019-12-19 11:37:48 +01:00
|
|
|
}
|
|
|
|
],
|
2019-12-26 16:19:26 +01:00
|
|
|
plugins: [...commonPlugins, ts(), !dev && terser()]
|
2019-12-22 16:38:10 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
input: inputFile,
|
|
|
|
output: [
|
|
|
|
{
|
2019-12-26 17:13:37 +01:00
|
|
|
file: _package.module,
|
2019-12-22 16:38:10 +01:00
|
|
|
format: 'esm',
|
|
|
|
sourcemap: true
|
|
|
|
}
|
|
|
|
],
|
2019-12-19 11:37:48 +01:00
|
|
|
plugins: [
|
2019-12-26 16:19:26 +01:00
|
|
|
...commonPlugins,
|
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
|
|
|
}),
|
2019-12-26 17:13:37 +01:00
|
|
|
!dev && terser(),
|
|
|
|
filesize({
|
|
|
|
showBrotliSize: true
|
|
|
|
})
|
2019-12-19 11:37:48 +01:00
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|