[6a3a178] | 1 | /* eslint-disable */
|
---|
| 2 |
|
---|
| 3 | // npm install rollup-plugin-typescript2 typescript --save-dev
|
---|
| 4 | import typescript from 'rollup-plugin-typescript2'
|
---|
| 5 | // import { terser } from 'rollup-plugin-terser'
|
---|
| 6 | // import resolve from 'rollup-plugin-node-resolve'
|
---|
| 7 |
|
---|
| 8 | // ------------------------------------------------------------------------------------------
|
---|
| 9 | // formats
|
---|
| 10 | // ------------------------------------------------------------------------------------------
|
---|
| 11 | // amd – Asynchronous Module Definition, used with module loaders like RequireJS
|
---|
| 12 | // cjs – CommonJS, suitable for Node and Browserify/Webpack
|
---|
| 13 | // esm – Keep the bundle as an ES module file
|
---|
| 14 | // iife – A self-executing function, suitable for inclusion as a <script> tag. (If you want to create a bundle for your application, you probably want to use this, because it leads to smaller file sizes.)
|
---|
| 15 | // umd – Universal Module Definition, works as amd, cjs and iife all in one
|
---|
| 16 | // system – Native format of the SystemJS loader
|
---|
| 17 |
|
---|
| 18 | // ------------------------------------------------------------------------------------------
|
---|
| 19 | // setup
|
---|
| 20 | // ------------------------------------------------------------------------------------------
|
---|
| 21 | const pkg = require('./package.json')
|
---|
| 22 | const name = pkg.name
|
---|
| 23 | const className = name.replace(/(^\w|-\w)/g, c => c.replace('-', '').toUpperCase())
|
---|
| 24 | const external = Object.keys(pkg.dependencies || [])
|
---|
| 25 | const plugins = [
|
---|
| 26 | typescript({ useTsconfigDeclarationDir: true, tsconfigOverride: { exclude: ['test/**/*'] } }),
|
---|
| 27 | ]
|
---|
| 28 |
|
---|
| 29 | // ------------------------------------------------------------------------------------------
|
---|
| 30 | // Builds
|
---|
| 31 | // ------------------------------------------------------------------------------------------
|
---|
| 32 | function defaults (config) {
|
---|
| 33 | // defaults
|
---|
| 34 | const defaults = {
|
---|
| 35 | plugins,
|
---|
| 36 | external,
|
---|
| 37 | }
|
---|
| 38 | // defaults.output
|
---|
| 39 | config.output = config.output.map(output => {
|
---|
| 40 | return Object.assign(
|
---|
| 41 | {
|
---|
| 42 | sourcemap: false,
|
---|
| 43 | name: className,
|
---|
| 44 | exports: 'named',
|
---|
| 45 | },
|
---|
| 46 | output
|
---|
| 47 | )
|
---|
| 48 | })
|
---|
| 49 | return Object.assign(defaults, config)
|
---|
| 50 | }
|
---|
| 51 |
|
---|
| 52 | export default [
|
---|
| 53 | defaults({
|
---|
| 54 | input: 'src/index.ts',
|
---|
| 55 | output: [
|
---|
| 56 | { file: 'dist/index.cjs.js', format: 'cjs' },
|
---|
| 57 | { file: 'dist/index.esm.js', format: 'esm' },
|
---|
| 58 | ],
|
---|
| 59 | }),
|
---|
| 60 | ]
|
---|