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

40 lines
945 B
JavaScript
Raw Normal View History

import commonjs from "@rollup/plugin-commonjs"
2021-01-21 17:44:03 +01:00
import resolve from "rollup-plugin-node-resolve"
2024-03-14 17:37:25 +01:00
import json from "@rollup/plugin-json"
import { terser } from "rollup-plugin-terser"
import builtins from "rollup-plugin-node-builtins"
import globals from "rollup-plugin-node-globals"
2024-02-21 20:45:35 +01:00
import typescript from "@rollup/plugin-typescript"
import injectProcessEnv from "rollup-plugin-inject-process-env"
const production = !process.env.ROLLUP_WATCH
2024-02-21 22:35:02 +01:00
const config = (format, outputFile) => ({
input: "src/index.ts",
output: {
sourcemap: !production,
format,
file: outputFile,
},
2024-02-21 22:35:02 +01:00
plugins: [
2024-03-14 17:28:35 +01:00
typescript(),
2024-02-21 22:35:02 +01:00
resolve({
preferBuiltins: true,
browser: true,
}),
commonjs(),
globals(),
builtins(),
2024-03-14 17:37:25 +01:00
json(),
2024-02-21 22:35:02 +01:00
injectProcessEnv({
NO_JS: process.env.NO_JS,
}),
2024-02-21 22:38:09 +01:00
production && terser(),
2024-02-21 22:35:02 +01:00
],
})
export default [
config("cjs", "./dist/bundle.cjs"),
config("esm", "./dist/bundle.mjs"),
]