You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
demoncord-rewrite/rollup.config.js

68 lines
1.4 KiB

import pkjs from "./package.json";
import { defineConfig } from "rollup";
import { nodeResolve } from "@rollup/plugin-node-resolve";
import alias from "@rollup/plugin-alias";
import { swc } from "rollup-plugin-swc3";
import { resolve as resolvePath } from "path";
import { visualizer } from "rollup-plugin-visualizer";
import TOML from "@ltd/j-toml";
import jscc from "rollup-plugin-jscc";
import { readFileSync as readFile, existsSync as fileExists } from "fs";
const projectRootDir = resolvePath(__dirname);
2 years ago
let data;
if (fileExists("options.toml")) {
2 years ago
data = readFile("options.toml");
} else if (fileExists("options.default.toml")) {
2 years ago
data = readFile("options.default.toml");
} else {
2 years ago
throw new Error("Could not find options file");
}
export default defineConfig({
input: pkjs.main,
output: {
file: "dist/build.js",
format: "iife"
},
external: ["React"],
plugins: [
jscc(TOML.parse(data)),
alias({
entries: [
{
find: "nests",
replacement: resolvePath(
projectRootDir,
"node_modules/nests/esm/"
)
},
{
find: "react",
replacement: resolvePath(
projectRootDir,
"src/shim_react.ts"
)
}
]
}),
nodeResolve(),
swc({
jsc: {
minify: {
compress: true
},
parser: {
syntax: "typescript",
tsx: true
},
target: "es2022",
baseUrl: "./src"
}
}),
visualizer()
]
});