budibase/packages/string-templates/rollup.config.js

44 lines
1.0 KiB
JavaScript
Raw Normal View History

import commonjs from "@rollup/plugin-commonjs"
2024-12-10 12:15:57 +01:00
import resolve from "@rollup/plugin-node-resolve"
2024-03-14 17:37:25 +01:00
import json from "@rollup/plugin-json"
2024-02-21 20:45:35 +01:00
import typescript from "@rollup/plugin-typescript"
2024-12-10 12:15:57 +01:00
import polyfillNode from "rollup-plugin-polyfill-node"
2024-03-18 12:37:05 +01:00
import inject from "@rollup/plugin-inject"
2024-12-10 12:15:57 +01:00
import { terser } from "rollup-plugin-terser"
const production = !process.env.ROLLUP_WATCH
2024-11-19 10:38:02 +01:00
const config = (input, outputFile, format) => ({
input,
2024-02-21 22:35:02 +01:00
output: {
sourcemap: !production,
format,
file: outputFile,
},
onwarn(warning, warn) {
if (warning.code === "EVAL") {
return
}
warn(warning)
},
2024-02-21 22:35:02 +01:00
plugins: [
2024-12-05 13:01:47 +01:00
typescript({
moduleResolution: "node",
}),
2024-12-10 12:18:27 +01:00
polyfillNode(),
2024-02-21 22:35:02 +01:00
resolve({
preferBuiltins: true,
browser: true,
}),
commonjs(),
2024-03-14 17:37:25 +01:00
json(),
2024-12-11 11:52:34 +01:00
inject({ Buffer: ["buffer", "Buffer"], process: "process/browser" }),
2024-02-21 22:38:09 +01:00
production && terser(),
2024-02-21 22:35:02 +01:00
],
})
export default [
2024-11-19 10:38:02 +01:00
config("src/index.ts", "./dist/bundle.cjs", "cjs"),
config("src/index.ts", "./dist/bundle.mjs", "esm"),
]