Configures ESBuild
This commit is contained in:
12
esbuild.config.mjs
Normal file
12
esbuild.config.mjs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import { build } from 'esbuild';
|
||||||
|
|
||||||
|
build({
|
||||||
|
entryPoints: ['src/main.ts'],
|
||||||
|
bundle: true,
|
||||||
|
target: 'es2018', // Screeps supports ES2018 well
|
||||||
|
platform: 'node',
|
||||||
|
format: 'cjs',
|
||||||
|
outdir: 'dist',
|
||||||
|
sourcemap: true,
|
||||||
|
logLevel: 'info',
|
||||||
|
}).catch(() => process.exit(1));
|
||||||
@@ -3,7 +3,8 @@
|
|||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"format": "prettier --config .prettierrc 'src/**/*.ts' --write && eslint --fix src/"
|
"format": "prettier --config .prettierrc 'src/**/*.ts' --write && eslint --fix src/",
|
||||||
|
"build": "node esbuild.config.mjs"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -31,6 +32,7 @@
|
|||||||
"@typescript-eslint/parser": "^8.35.1",
|
"@typescript-eslint/parser": "^8.35.1",
|
||||||
"@typescript-eslint/typescript-estree": "^8.35.1",
|
"@typescript-eslint/typescript-estree": "^8.35.1",
|
||||||
"chai": "^5.2.0",
|
"chai": "^5.2.0",
|
||||||
|
"esbuild": "^0.25.5",
|
||||||
"eslint": "^9.30.1",
|
"eslint": "^9.30.1",
|
||||||
"eslint-config-prettier": "^10.1.5",
|
"eslint-config-prettier": "^10.1.5",
|
||||||
"eslint-import-resolver-typescript": "^4.4.4",
|
"eslint-import-resolver-typescript": "^4.4.4",
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
|
|
||||||
import clear from 'rollup-plugin-clear';
|
|
||||||
import resolve from '@rollup/plugin-node-resolve';
|
|
||||||
import commonjs from '@rollup/plugin-commonjs';
|
|
||||||
import typescript from 'rollup-plugin-typescript2';
|
|
||||||
import screeps from 'rollup-plugin-screeps';
|
|
||||||
|
|
||||||
let cfg;
|
|
||||||
const dest = process.env.DEST;
|
|
||||||
if (!dest) {
|
|
||||||
console.log("No destination specified - code will be compiled but not uploaded");
|
|
||||||
} else if ((cfg = require("./screeps.json")[dest]) == null) {
|
|
||||||
throw new Error("Invalid upload destination");
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
|
||||||
input: "src/main.ts",
|
|
||||||
output: {
|
|
||||||
file: "dist/main.js",
|
|
||||||
format: "cjs",
|
|
||||||
sourcemap: true
|
|
||||||
},
|
|
||||||
|
|
||||||
plugins: [
|
|
||||||
clear({ targets: ["dist"] }),
|
|
||||||
resolve({ rootDir: "src" }),
|
|
||||||
commonjs(),
|
|
||||||
typescript({tsconfig: "./tsconfig.json"}),
|
|
||||||
screeps({config: cfg, dryRun: cfg == null})
|
|
||||||
]
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user