2021-01-30 03:54:52 +01:00
|
|
|
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"
|
2021-01-30 01:20:13 +01:00
|
|
|
import { terser } from "rollup-plugin-terser"
|
2021-04-01 17:09:16 +02:00
|
|
|
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"
|
2022-09-07 09:48:29 +02:00
|
|
|
import injectProcessEnv from "rollup-plugin-inject-process-env"
|
2024-03-18 12:37:05 +01:00
|
|
|
import inject from "@rollup/plugin-inject"
|
2021-01-18 18:40:19 +01:00
|
|
|
|
2021-01-30 01:20:13 +01:00
|
|
|
const production = !process.env.ROLLUP_WATCH
|
2021-03-31 17:14:56 +02:00
|
|
|
|
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,
|
2021-03-31 17:14:56 +02:00
|
|
|
},
|
2024-03-27 14:35:47 +01:00
|
|
|
onwarn(warning, warn) {
|
|
|
|
if (warning.code === "EVAL") {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
warn(warning)
|
|
|
|
},
|
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(),
|
2024-03-18 12:37:05 +01:00
|
|
|
inject({ Buffer: ["buffer", "Buffer"] }),
|
2024-02-21 22:35:02 +01:00
|
|
|
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 [
|
2024-11-19 10:38:02 +01:00
|
|
|
config("src/index.ts", "./dist/bundle.cjs", "cjs"),
|
|
|
|
config("src/index.ts", "./dist/bundle.mjs", "esm"),
|
|
|
|
config("src/iife.ts", "./dist/iife.mjs", "esm"),
|
2021-03-31 17:14:56 +02:00
|
|
|
]
|