-
Notifications
You must be signed in to change notification settings - Fork 16
/
rollup.config.js
66 lines (63 loc) · 1.63 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
import path from 'path'
import alias from '@rollup/plugin-alias'
import babel from 'rollup-plugin-babel'
import image from '@rollup/plugin-image'
import json from '@rollup/plugin-json'
import metablock from 'rollup-plugin-userscript-metablock'
import postcss from 'rollup-plugin-postcss'
import replace from '@rollup/plugin-replace'
import resolve from '@rollup/plugin-node-resolve'
import precss from 'precss'
import { fileURLToPath } from 'url'
import pkg from './package.json' with { type: 'json' }
const __dirname = path.dirname(fileURLToPath(import.meta.url))
const production = !process.env.ROLLUP_WATCH
export default {
input: 'src/main.jsx',
output: {
file: 'imdb-link-em-all.user.js',
format: 'iife',
globals: {
preact: 'preact',
'preact/hooks': 'preactHooks',
},
},
external: ['preact', 'preact/hooks'],
plugins: [
alias({
entries: [
{
find: pkg.name,
replacement: path.resolve(__dirname, 'src'),
},
],
}),
resolve({
extensions: ['.js', '.jsx'],
}),
postcss({
parser: 'sugarss',
plugins: [precss()],
modules: true,
minimize: false,
sourceMap: production ? false : 'inline',
}),
babel({
exclude: 'node_modules/**',
}),
image(),
json({ namedExports: true }),
replace({
__SITES_URL__: production ? pkg.config.sitesUrl : 'http://localhost:8001/sites.json',
include: 'src/constants.js',
preventAssignment: true,
}),
metablock({
override: {
author: pkg.author,
description: pkg.description,
version: pkg.version,
},
}),
],
}