-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
48 lines (42 loc) · 1.12 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
"use strict";
import typescript from "rollup-plugin-typescript2";
import commonjs from "rollup-plugin-commonjs";
import resolve from "rollup-plugin-node-resolve";
import replace from "rollup-plugin-replace";
let tsconfig = require("./tsconfig.json").compilerOptions;
// In Screeps, require works different and expects actual code
// This "plugin" merely prepends "module.exports = " to the source map so that it can be loaded in Screeps properly
function exportSourceMaps() {
return {
name: "export-source-maps",
ongenerate: function(options, bundle) {
let oldToString = bundle.map.toString;
bundle.map.toString = function() {
console.log("Adding module export to source map");
return "module.exports = " + oldToString.apply(this, arguments);
}
}
};
}
delete tsconfig.module;
tsconfig.typescript = require("typescript");
export default {
input: "src/Main.ts",
output: {
format: "cjs",
file: "dist/main.js"
},
sourcemap: true,
plugins: [
resolve(),
commonjs(),
replace({
delimiters: ['__', '__'],
values: {
PROFILER_ENABLED: "true"
}
}),
typescript(tsconfig),
exportSourceMaps()
]
}