-
-
Notifications
You must be signed in to change notification settings - Fork 35
/
rollup.config.js
73 lines (67 loc) · 2.22 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
import typescript from 'rollup-plugin-typescript2'
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs';
import clear from 'rollup-plugin-clear'
import screeps from 'rollup-plugin-screeps-world'
import copy from 'rollup-plugin-copy';
import { terser } from 'rollup-plugin-terser'
import yaml from 'yaml'
import { readFileSync } from 'fs'
let config
const dest = process.env.DEST
if (!dest) {
console.log('No destination specified - code will be compiled but not uploaded')
} else {
config = (yaml.parse(readFileSync('.screeps.yaml', { encoding: 'utf8' })).servers || {})[dest]
if (config == null) throw new Error('Invalid upload destination')
config.hostname = config.host
config.port = config.port || (config.secure ? 443 : 21025)
config.host = `${config.host}:${config.port}`
config.email = config.username
config.protocol = config.secure ? 'https' : 'http'
config.path = config.path || '/'
config.branch = config.branch || 'auto'
}
const shouldUglify = config && config.uglify
const ignoreWarningTypes = new Set([
'Circular dependency',
])
export default {
inlineDynamicImports: true,
input: 'src/main.ts',
output: {
file: 'dist/main.js',
format: 'cjs',
sourcemap: true,
banner:
`
// The International Screeps Bot
// DO NOT USE THIS BOT TO BULLY PLAYERS
// code repository: https://github.com/The-International-Screeps-Bot/The-International-Open-Source
`
},
plugins: [
clear({ targets: ['dist'] }),
copy({
targets: [
{ src: 'src/wasm/pkg/commiebot_wasm_bg.wasm', dest: 'dist' },
]
}),
resolve(),
commonjs({
ignoreTryCatch: false
}),
shouldUglify && terser(),
typescript({ tsconfig: './tsconfig.json' }),
screeps({ config: config, dryRun: !config }),
],
/**
* Skip over certain blacklisten warnings that we don't need to be concerned about
*/
onwarn: function (warning) {
// Skip warning types we don't care about
if (ignoreWarningTypes.has(warning.toString().split(':')[0])) return
// warn about everything else
console.warn(warning.message)
},
}