fix sourcemap uploading issue due to filename
This commit is contained in:
@@ -1,13 +1,17 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
import fs from "fs";
|
||||||
|
import path from "path";
|
||||||
import resolve from "rollup-plugin-node-resolve";
|
import resolve from "rollup-plugin-node-resolve";
|
||||||
import commonjs from "rollup-plugin-commonjs";
|
import commonjs from "rollup-plugin-commonjs";
|
||||||
import screepsUpload from "rollup-plugin-screeps-upload";
|
import screepsUpload from "rollup-plugin-screeps-upload";
|
||||||
import typescript from "rollup-plugin-typescript2";
|
import typescript from "rollup-plugin-typescript2";
|
||||||
|
|
||||||
|
const getSourcemapFilename = () => 'main.js.map.js'
|
||||||
|
|
||||||
// In Screeps, require only works for exported content
|
// In Screeps, require only works for exported content
|
||||||
// This "plugin" prepends an export to source maps so that it can be loaded in screeps via require`
|
// This "plugin" prepends an export to source maps so that it can be loaded in screeps via require`
|
||||||
function exportSourceMaps() {
|
function exportSourceMaps(options) {
|
||||||
return {
|
return {
|
||||||
name: "export-source-maps",
|
name: "export-source-maps",
|
||||||
ongenerate: function (options, bundle) {
|
ongenerate: function (options, bundle) {
|
||||||
@@ -18,6 +22,12 @@ function exportSourceMaps() {
|
|||||||
bundle.map.toString = function () {
|
bundle.map.toString = function () {
|
||||||
return "module.exports = " + tmp.apply(this, arguments) + ";";
|
return "module.exports = " + tmp.apply(this, arguments) + ";";
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
onwrite: function ({ bundle }) {
|
||||||
|
const map = bundle.map
|
||||||
|
fs.writeFileSync(path.resolve(__dirname, `./dist/${options || getSourcemapFilename()}`), map);
|
||||||
|
// Delete the old file
|
||||||
|
fs.unlinkSync(path.resolve(__dirname, `./dist/main.js.map`));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -35,7 +45,7 @@ export default {
|
|||||||
resolve(),
|
resolve(),
|
||||||
commonjs(),
|
commonjs(),
|
||||||
typescript({tsconfig: "./tsconfig.json"}),
|
typescript({tsconfig: "./tsconfig.json"}),
|
||||||
exportSourceMaps(),
|
exportSourceMaps("main.js.map.js"),
|
||||||
screepsUpload('./screeps.json')
|
screepsUpload("./screeps.json")
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user