forked from grompe/Drawception-ANBT
-
Notifications
You must be signed in to change notification settings - Fork 3
/
rollup.config.js
130 lines (127 loc) · 2.86 KB
/
rollup.config.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import fs from 'fs'
import cleanup from 'rollup-plugin-cleanup'
import clear from 'rollup-plugin-clear'
import commonjs from 'rollup-plugin-commonjs'
import copy from 'rollup-plugin-copy'
import { eslint } from 'rollup-plugin-eslint'
import resolve from 'rollup-plugin-node-resolve'
import prettier from 'rollup-plugin-prettier'
import replaceHtmlVars from 'rollup-plugin-replace-html-vars'
import scss from 'rollup-plugin-scss'
import { terser } from 'rollup-plugin-terser'
import { banner } from './src/extension/banner'
const waitFile = path => {
return new Promise(resolve => {
const interval = setInterval(() => {
if (!fs.existsSync(path)) return
clearInterval(interval)
resolve(path)
}, 100)
})
}
clear({
targets: ['build/'],
watch: true
})
export default [
{
input: 'src/newcanvas/js/pako.js',
output: {
format: 'iife',
file: 'build/newcanvas/pako.js'
},
plugins: [
commonjs(),
resolve(),
cleanup(),
eslint({
exclude: ['/build/*.js']
}),
terser()
]
},
{
input: 'src/newcanvas/js/pathseg.js',
output: {
format: 'iife',
file: 'build/newcanvas/pathseg.js'
},
plugins: [
commonjs(),
resolve(),
cleanup(),
eslint({
exclude: ['/build/*.js']
}),
terser()
]
},
{
input: 'src/newcanvas.js',
output: {
format: 'iife',
file: 'build/newcanvas/script.js'
},
plugins: [
scss({
output: 'build/newcanvas/style.css',
outputStyle: 'compressed'
}),
commonjs(),
resolve(),
cleanup(),
eslint({
exclude: ['/build/*.js']
}),
prettier({
cwd: __dirname,
semi: true
}),
copy({
targets: [
{ src: 'src/newcanvas/html/index.html', dest: 'build/newcanvas' }
]
})
]
},
{
input: 'src/extension.js',
output: {
format: 'iife',
file: 'build/drawception-anbt.user.js',
banner
},
plugins: [
commonjs(),
resolve(),
cleanup(),
eslint({
exclude: ['/build/*.js']
}),
prettier({
cwd: __dirname,
semi: true
}),
copy({
targets: [{ src: 'build/newcanvas/index.html', dest: 'build/' }]
}),
waitFile('build/index.html').then(file => {
replaceHtmlVars({
files: file,
from: [
'/*NEWCANVAS_STYLE*/',
'/*PAKO_SCRIPT*/',
'/*PATHSEG_SCRIPT*/',
'/*NEWCANVAS_SCRIPT*/'
],
to: [
fs.readFileSync('build/newcanvas/style.css', 'utf8'),
fs.readFileSync('build/newcanvas/pako.js', 'utf8'),
fs.readFileSync('build/newcanvas/pathseg.js', 'utf8'),
fs.readFileSync('build/newcanvas/script.js', 'utf8')
]
})
})
]
}
]