budibase/packages/client/rollup.config.js

100 lines
2.3 KiB
JavaScript
Raw Normal View History

import commonjs from "@rollup/plugin-commonjs"
import resolve from "@rollup/plugin-node-resolve"
import alias from "@rollup/plugin-alias"
import svelte from "rollup-plugin-svelte"
import { terser } from "rollup-plugin-terser"
2021-04-01 14:44:14 +02:00
import postcss from "rollup-plugin-postcss"
import svg from "rollup-plugin-svg"
import image from "@rollup/plugin-image"
2021-04-01 14:44:14 +02:00
import json from "rollup-plugin-json"
import nodePolyfills from "rollup-plugin-polyfill-node"
import path from "path"
import { visualizer } from "rollup-plugin-visualizer"
const production = !process.env.ROLLUP_WATCH
2021-04-01 20:25:56 +02:00
const ignoredWarnings = [
"unused-export-let",
"css-unused-selector",
"module-script-reactive-declaration",
"a11y-no-onchange",
]
2019-09-06 14:04:23 +02:00
export default {
input: "src/index.js",
output: [
{
2021-04-01 14:44:14 +02:00
sourcemap: false,
2021-01-07 15:53:18 +01:00
format: "iife",
file: `./dist/budibase-client.js`,
},
],
onwarn(warning, warn) {
if (
warning.code === "THIS_IS_UNDEFINED" ||
warning.code === "CIRCULAR_DEPENDENCY"
) {
return
}
warn(warning)
},
plugins: [
alias({
entries: [
{
find: "manifest.json",
replacement: path.resolve("./manifest.json"),
},
{
find: "api",
replacement: path.resolve("./src/api"),
},
{
find: "components",
replacement: path.resolve("./src/components"),
},
{
find: "stores",
replacement: path.resolve("./src/stores"),
},
{
find: "utils",
replacement: path.resolve("./src/utils"),
},
{
find: "constants",
replacement: path.resolve("./src/constants"),
},
{
find: "sdk",
replacement: path.resolve("./src/sdk"),
},
],
}),
svelte({
2021-04-01 14:44:14 +02:00
emitCss: true,
2021-04-01 20:25:56 +02:00
onwarn: (warning, handler) => {
// Ignore some warnings
if (!ignoredWarnings.includes(warning.code)) {
handler(warning)
}
},
}),
2021-04-01 14:44:14 +02:00
postcss(),
commonjs(),
nodePolyfills(),
resolve({
preferBuiltins: true,
browser: true,
dedupe: ["svelte", "svelte/internal"],
}),
2021-04-01 14:44:14 +02:00
svg(),
image(),
2021-04-01 14:44:14 +02:00
json(),
production && terser(),
!production && visualizer(),
],
watch: {
clearScreen: false,
},
}