-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.raw.js
53 lines (50 loc) · 1.61 KB
/
rollup.config.raw.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
import commonjs from 'rollup-plugin-commonjs'
import nodeResolve from 'rollup-plugin-node-resolve'
import { uglify } from 'rollup-plugin-uglify'
import babel from 'rollup-plugin-babel'
import html from 'rollup-plugin-html'
import replace from 'rollup-plugin-replace'
const version = require('./package.json').version
const dotAttrWrapOpen = /\{\{[~?=][^}]+\}\}/;
const dotAttrWrapClose = /\{\{\/[^}]+\}\}/;
const dotAttrWrapPair = [dotAttrWrapOpen, dotAttrWrapClose];
export function generate() {
return {
input: 'src/bookmarklet.js',
output: {
format: 'iife',
file: 'demo/bundle.js'
},
plugins: [
replace({
PKG_VERSION: JSON.stringify(version)
}),
nodeResolve(),
commonjs({
// non-CommonJS modules will be ignored, but you can also
// specifically include/exclude files
include: ['node_modules/**'], // Default: undefined
sourceMap: false,
}),
html({
include: ['src/**/*.html', 'src/**/*.dot'],
htmlMinifierOptions: {
collapseWhitespace: process.env.NODE_ENV === 'Production',
minifyCSS: process.env.NODE_ENV === 'Production',
customAttrSurround: [dotAttrWrapPair],
},
}),
babel({
babelrc: false,
plugins: ['transform-exponentiation-operator', 'transform-object-rest-spread', 'external-helpers'],
presets: [['env', { modules: false }]],
exclude: 'node_modules/**' // only transpile our source code
}),
process.env.NODE_ENV === 'Production' && uglify({
output: {
quote_style: 1,
},
}),
]
}
}