-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathbuild.js
57 lines (50 loc) · 1.69 KB
/
build.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const rollup = require('rollup')
const resolve = require('rollup-plugin-node-resolve')
const commonjs = require('rollup-plugin-commonjs')
const sourceMaps = require('rollup-plugin-sourcemaps')
const typescript = require('rollup-plugin-typescript2')
const json = require('rollup-plugin-json')
const camelCase = require('lodash.camelcase')
const uglify = require('rollup-plugin-uglify').uglify
const pkg = require('./package.json')
const libraryName = 'paperjsOffset'
const defaultPlugins = [
json(),
typescript({ useTsconfigDeclarationDir: true }),
commonjs(),
resolve(),
sourceMaps(),
]
let tasks = []
tasks.push(rollup.rollup({
input: 'src/index.ts',
external: ['paper'],
plugins: defaultPlugins
}).then(bundle => {
bundle.write({ format: 'umd', file: pkg.main, name: camelCase(libraryName), sourcemap: true })
bundle.write({ format: 'es', file: pkg.module, name: camelCase(libraryName), sourcemap: true })
}))
tasks.push(rollup.rollup({
input: 'src/bundle.ts',
output: [
{ file: 'dist/paperjs-offset.js', format: 'iife', sourcemap: false },
],
external: ['paper'],
plugins: defaultPlugins
}).then(bundle => {
bundle.write({ format: 'iife', file: 'dist/paperjs-offset.js', sourcemap: false })
bundle.write({ format: 'iife', file: 'demo/paperjs-offset.js', sourcemap: false })
}))
tasks.push(rollup.rollup({
input: 'src/bundle.ts',
external: ['paper'],
plugins: defaultPlugins.concat([uglify()])
}).then(bundle => {
bundle.write({ format: 'iife', file: 'dist/paperjs-offset.min.js', sourcemap: false })
bundle.write({ format: 'iife', file: 'demo/paperjs-offset.min.js', sourcemap: false })
}))
Promise.all(tasks).then(() => {
setTimeout(() => {
process.exit()
}, 3000)
})