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