|
|
|
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";
|
|
|
|
import typescript from "@rollup/plugin-typescript";
|
|
|
|
|
|
|
|
const projectRootDir = resolvePath(__dirname);
|
|
|
|
|
|
|
|
let data;
|
|
|
|
|
|
|
|
if (fileExists("options.toml")) {
|
|
|
|
data = readFile("options.toml");
|
|
|
|
} else if (fileExists("options.default.toml")) {
|
|
|
|
data = readFile("options.default.toml");
|
|
|
|
} else {
|
|
|
|
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"
|
|
|
|
)
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}),
|
|
|
|
typescript(),
|
|
|
|
nodeResolve(),
|
|
|
|
swc({
|
|
|
|
jsc: {
|
|
|
|
minify: {
|
|
|
|
compress: true
|
|
|
|
},
|
|
|
|
parser: {
|
|
|
|
syntax: "typescript",
|
|
|
|
tsx: true
|
|
|
|
},
|
|
|
|
target: "es2022",
|
|
|
|
baseUrl: "./src"
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
visualizer()
|
|
|
|
]
|
|
|
|
});
|