-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrollup.config.mjs
138 lines (128 loc) · 3.33 KB
/
rollup.config.mjs
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
131
132
133
134
135
136
137
138
import commonjs from '@rollup/plugin-commonjs'
import copy from 'rollup-plugin-copy'
import eslint from '@rollup/plugin-eslint'
import execute from 'rollup-plugin-execute'
import resolve from '@rollup/plugin-node-resolve'
import preprocess from 'svelte-preprocess'
import sass from 'rollup-plugin-sass'
import svelte from 'rollup-plugin-svelte'
import terser from '@rollup/plugin-terser'
import { isDev, outputDir, target } from './utils.config.mjs'
const format = 'es'
const sourcemap = (isDev ? 'inline' : false)
const verbose = true
const plugins = [
eslint({
exclude: [
'src/**/*.{css,sass}',
]
}),
svelte({
emitCss: true,
compilerOptions: {
// enable run-time checks when not in production
dev: isDev,
},
preprocess: preprocess({
style: sass(),
}),
}),
sass(),
// Convert CommonJS libraries to ES6
resolve({
browser: true, // default: false
modulesOnly: false, // default: false
dedupe: ['svelte'],
modulePaths: [
'./node_modules/'
],
preferBuiltins: false,
}),
commonjs(),
!isDev && terser(),
]
const copyAssets = [
execute([
`TARGET=${target} ./bin/generateManifest.js`,
]),
copy({
targets: [{
src: [
'src/**/*.html',
],
dest: outputDir('views'),
}],
flatten: true,
verbose,
}),
copy({
targets: [{
src: [
'src/_locales/**/*.json',
'src/img/spellbook-bg.jpg',
'src/img/spellbook_icon*.png',
],
dest: outputDir(),
}],
flatten: false,
verbose,
}),
copy({
targets: [{
src: [
'node_modules/spectre.css/dist/spectre-icons.css',
'node_modules/spectre.css/dist/spectre.css',
],
dest: outputDir('style'),
}],
flatten: true,
verbose,
}),
]
const watch = {
chokidar: true,
clearScreen: true,
exclude: ['node_modules/**'],
include: ['src/**/*'],
}
export default [
{
input: 'src/style/popup.scss',
output: {
dir: outputDir('style'),
name: 'popup.scss',
format,
},
plugins: [
sass({
output: outputDir('style/popup.css'),
})
],
watch,
},
{
input: {
background: 'src/js/background/script.js',
popup: 'src/js/popup.js',
serviceWorker: 'src/js/background/worker.js',
},
output: {
dir: outputDir('js'),
entryFileNames: '[name].js',
format,
manualChunks: {
api: ['./src/js/api/categories.js', './src/js/api/tabs.js'],
icons: ['./src/js/lib/icons.js'],
'ext/events': ['events'],
'ext/kefir': ['kefir'],
'ext/rambda': ['rambda'],
'ext/svelte': ['svelte', 'svelte/store'],
'ext/webextension-polyfill': ['webextension-polyfill'],
'ext/zepto-detect': ['zepto-detect'],
},
sourcemap,
},
plugins: plugins.concat(copyAssets),
watch,
}
]