-
Notifications
You must be signed in to change notification settings - Fork 12
/
rollup.config.js
99 lines (97 loc) · 2.58 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
import svelte from 'rollup-plugin-svelte';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import { terser } from 'rollup-plugin-terser';
import sveltePreprocess from 'svelte-preprocess';
import pug from 'rollup-plugin-pug';
import typescript from '@rollup/plugin-typescript';
import replace from '@rollup/plugin-replace';
import userscript from './rollup-plugin-userscript';
const { name: APP_TITLE, version: APP_VERSION } = require('./package.json');
const APP_ICON = 'https://raw.githubusercontent.com/Taraflex/ranobe-ebook-loader/master/icons/32.png';
const dev = !!process.env.ROLLUP_WATCH
export default {
input: 'src/main.ts',
preserveEntrySignatures: false,
strictDeprecations: true,
output: {
dir: 'build',
sourcemap: dev && 'inline'
},
plugins: [
svelte({
emitCss: false,
preprocess: sveltePreprocess({
sourceMap: false,
typescript: {
compilerOptions: {
sourceMap: false,
noUnusedLocals: !dev,
noUnusedParameters: !dev,
}
},
scss: { sourceMap: false },
sass: { sourceMap: false },
//@ts-ignore
postcss: dev ? {
map: false,
plugins: [require('autoprefixer')]
} : {
map: false,
plugins: [require('postcss-flexbugs-fixes'), require('autoprefixer'), require('cssnano')]
}
})
}),
resolve({ dedupe: ['svelte'], browser: true }),
commonjs({ sourceMap: dev }),
typescript({
noUnusedLocals: !dev,
noUnusedParameters: !dev,
inlineSourceMap: dev,
inlineSources: dev,
}),
replace({
include: /\.(ts|svelte)$/,
values: {
APP_TITLE_noquotes: APP_TITLE,
APP_ICON: `"${APP_ICON}"`,
APP_VERSION: `"${APP_VERSION}"`,
APP_TITLE: `"${APP_TITLE}"`,
}
}),
dev ? 0 : terser({
ecma: 2018,
module: true,
compress: {
passes: 2,
unsafe_arrows: true
},
format: {
comments: /^\s+[=@][^t]/
}
}),
pug({ sourceMap: dev, pretty: dev }),
userscript({
meta: {
downloadURL: 'https://raw.githubusercontent.com/Taraflex/ranobe-ebook-loader/master/build/ranobe-ebook-loader.user.js',
icon: APP_ICON,
icon64: APP_ICON.replace('32.png', '64.png'),
match: [
'https://ранобэ.рф/*',
'https://xn--80ac9aeh6f.xn--p1ai/*',
'https://ranobes.com/ranobe/*',
'https://tl.rulate.ru/book/*',
'https://jaomix.ru/*'
],
'run-at': 'document-idle',
grant: ['GM_registerMenuCommand', 'GM_unregisterMenuCommand', 'GM_xmlhttpRequest', 'GM.xmlHttpRequest'],
connect: '*',
noframes: ''
},
hot: dev && 'patch'
})
].filter(Boolean),
watch: {
clearScreen: false
}
};