forked from antoniandre/vueper-slides
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
68 lines (63 loc) · 1.86 KB
/
build.js
File metadata and controls
68 lines (63 loc) · 1.86 KB
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
58
59
60
61
62
63
64
65
66
67
68
import { rollup, watch } from 'rollup'
import babel from 'rollup-plugin-babel'
import resolve from 'rollup-plugin-node-resolve'
import vue from 'rollup-plugin-vue'
import pug from 'rollup-plugin-pug'
// const eslint = require('rollup-plugin-eslint')
import { uglify } from 'rollup-plugin-uglify'
import postcss from 'rollup-plugin-postcss'
import sass from 'rollup-plugin-sass'
import autoprefixer from 'autoprefixer'
const libName = 'vueperslides'
const config = (min = false) => {
return {
input: 'src/index.js',
output: {
file: `dist/${libName}${min ? '.min' : ''}.js`,
name: 'VueperSlides',
sourcemap: min,
format: 'umd'
},
plugins: [
resolve(),
vue({ compileTemplate: true, css: true }),
pug(),
postcss({
extract: `dist/${libName}.min.css`,
plugins: [autoprefixer],
// sourceMap: true,
minimize: true
}),
babel({ exclude: 'node_modules/**' }),
(min && uglify())
]
}
}
// stderr to keep `rollup main.js > bundle.js` from breaking.
const stderr = console.error.bind(console)
const eventHandler = (event, filename) => {
switch (event.code) {
case 'START':
stderr('checking rollup-watch version...')
break
case 'BUNDLE_START':
stderr(`bundling to ${filename}...`)
break
case 'BUNDLE_END':
stderr(`${filename} bundled in ${event.duration}ms. Watching for changes..`)
break
case 'END':
// stderr(`Bundle done.`)
break
case 'ERROR':
stderr(`Error: ${event.error}`)
break
case 'FATAL':
stderr(`Fatal error: ${event.error}`)
break
default:
stderr(`Unknown event: ${JSON.stringify(event, null, 2)}`)
}
}
watch(config()).on('event', (event) => eventHandler(event, `dist/${libName}.js`))
watch(config(true)).on('event', (event) => eventHandler(event, `dist/${libName}.min.js`))