-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
rollup.config.js
97 lines (91 loc) · 3.01 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
import filesize from 'rollup-plugin-filesize'
import replace from '@rollup/plugin-replace'
import copy from 'rollup-plugin-copy'
import resolve from '@rollup/plugin-node-resolve'
import postcss from 'rollup-plugin-postcss'
import serve from 'rollup-plugin-serve'
import pkg from './package.json'
import { dependencies } from './package-lock.json'
import { renderPanel, watch } from './packages/build/index'
renderPanel()
const isWatch = process.env.ROLLUP_WATCH === 'true'
const shouldServe = process.env.ROLLUP_SERVE === 'true' || isWatch
if (isWatch) {
watch({
assetsDir: 'packages/shell-chrome/assets',
viewsDir: 'packages/shell-chrome/views',
outputDir: 'dist/chrome',
})
}
const JS_INPUTS = [
'packages/shell-chrome/src/backend.js',
'packages/shell-chrome/src/background.js',
'packages/shell-chrome/src/devtools-background.js',
'packages/shell-chrome/src/proxy.js',
'packages/shell-chrome/src/detector.js',
]
const MIXED_INPUT = ['packages/shell-chrome/src/devtools/panel.js']
if (shouldServe) {
MIXED_INPUT.push('packages/simulator/dev.js')
}
const output = {
dir: 'dist/chrome',
format: 'iife',
}
export default [
// create standalone builds to avoid rollup creating a common "utils" chunk
...JS_INPUTS.map((input) => ({
input,
output,
plugins: [
replace({
preventAssignment: true,
__alpine_version__: dependencies.alpinejs.version,
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
}),
resolve(),
filesize(),
],
})),
...MIXED_INPUT.map((input) => ({
input,
output,
plugins: [
replace({
preventAssignment: true,
__alpine_version__: dependencies.alpinejs.version,
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
}),
resolve(),
postcss({
extract: 'styles.css',
}),
copy({
targets: [
{
src: 'packages/shell-chrome/assets/**/*',
dest: 'dist/chrome',
},
{
src: 'node_modules/alpinejs/dist/alpine.js',
dest: 'dist/chrome',
},
{
src: 'packages/shell-chrome/assets/manifest.json',
dest: 'dist/chrome',
// inject version into manifest
transform(contents) {
return contents.toString().replace('__version__', pkg.version)
},
},
],
}),
filesize(),
shouldServe &&
serve({
port: process.env.PORT || 8080,
contentBase: ['./dist/chrome', './packages/simulator'],
}),
],
})),
]