2020-04-01 23:38:07 +13:00
|
|
|
import alias from "@rollup/plugin-alias"
|
2020-02-03 22:24:25 +13:00
|
|
|
import svelte from "rollup-plugin-svelte"
|
|
|
|
import resolve from "rollup-plugin-node-resolve"
|
2020-11-19 08:18:18 +13:00
|
|
|
import commonjs from "@rollup/plugin-commonjs"
|
2020-02-03 22:24:25 +13:00
|
|
|
import url from "rollup-plugin-url"
|
|
|
|
import livereload from "rollup-plugin-livereload"
|
|
|
|
import { terser } from "rollup-plugin-terser"
|
|
|
|
import builtins from "rollup-plugin-node-builtins"
|
|
|
|
import nodeglobals from "rollup-plugin-node-globals"
|
|
|
|
import copy from "rollup-plugin-copy"
|
2020-09-09 23:06:04 +12:00
|
|
|
import css from "rollup-plugin-css-only"
|
2020-03-05 05:47:47 +13:00
|
|
|
import replace from "rollup-plugin-replace"
|
2020-05-07 21:53:34 +12:00
|
|
|
import json from "@rollup/plugin-json"
|
2020-12-02 05:22:06 +13:00
|
|
|
import html from "rollup-plugin-html"
|
2019-07-13 21:35:57 +12:00
|
|
|
|
2020-04-01 23:38:07 +13:00
|
|
|
import path from "path"
|
|
|
|
|
2020-02-03 22:24:25 +13:00
|
|
|
const production = !process.env.ROLLUP_WATCH
|
|
|
|
const outputpath = "../server/builder"
|
2019-07-30 20:08:40 +12:00
|
|
|
const coreExternal = [
|
2020-02-03 22:24:25 +13:00
|
|
|
"lodash",
|
|
|
|
"lodash/fp",
|
|
|
|
"date-fns",
|
|
|
|
"lunr",
|
|
|
|
"safe-buffer",
|
|
|
|
"shortid",
|
|
|
|
"@nx-js/compiler-util",
|
|
|
|
]
|
2019-07-30 20:08:40 +12:00
|
|
|
|
2020-04-01 23:38:07 +13:00
|
|
|
const customResolver = resolve({
|
2020-05-07 21:53:34 +12:00
|
|
|
extensions: [
|
|
|
|
".mjs",
|
|
|
|
".js",
|
|
|
|
".jsx",
|
|
|
|
".json",
|
|
|
|
".sass",
|
|
|
|
".scss",
|
|
|
|
".svelte",
|
|
|
|
".css",
|
|
|
|
],
|
2020-04-01 23:38:07 +13:00
|
|
|
})
|
|
|
|
const projectRootDir = path.resolve(__dirname)
|
|
|
|
|
2019-07-13 21:35:57 +12:00
|
|
|
export default {
|
2020-02-03 22:24:25 +13:00
|
|
|
input: "src/main.js",
|
|
|
|
output: {
|
|
|
|
sourcemap: true,
|
|
|
|
format: "iife",
|
|
|
|
name: "app",
|
|
|
|
file: `${outputpath}/bundle.js`,
|
|
|
|
},
|
|
|
|
plugins: [
|
2020-04-01 23:38:07 +13:00
|
|
|
alias({
|
|
|
|
entries: [
|
2020-04-17 21:26:48 +12:00
|
|
|
{
|
|
|
|
find: "components",
|
|
|
|
replacement: path.resolve(projectRootDir, "src/components"),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
find: "builderStore",
|
|
|
|
replacement: path.resolve(projectRootDir, "src/builderStore"),
|
|
|
|
},
|
2020-06-16 03:41:31 +12:00
|
|
|
{
|
|
|
|
find: "constants",
|
|
|
|
replacement: path.resolve(projectRootDir, "src/constants"),
|
|
|
|
},
|
2020-09-30 03:26:56 +13:00
|
|
|
{
|
|
|
|
find: "analytics",
|
|
|
|
replacement: path.resolve(projectRootDir, "src/analytics"),
|
|
|
|
},
|
2020-04-01 23:38:07 +13:00
|
|
|
],
|
2020-04-17 21:26:48 +12:00
|
|
|
customResolver,
|
2020-04-01 23:38:07 +13:00
|
|
|
}),
|
2020-02-03 22:24:25 +13:00
|
|
|
copy({
|
|
|
|
targets: [
|
2020-04-02 22:44:42 +13:00
|
|
|
{ src: "src/index.html", dest: outputpath },
|
2020-02-03 22:24:25 +13:00
|
|
|
{ src: "src/favicon.png", dest: outputpath },
|
2020-05-06 21:33:30 +12:00
|
|
|
{ src: "assets", dest: outputpath },
|
2020-02-03 22:24:25 +13:00
|
|
|
{
|
|
|
|
src: "node_modules/@budibase/client/dist/budibase-client.esm.mjs",
|
|
|
|
dest: outputpath,
|
|
|
|
},
|
2020-06-19 23:36:03 +12:00
|
|
|
{
|
|
|
|
src: "node_modules/@budibase/bbui/dist/bbui.css",
|
|
|
|
dest: outputpath,
|
|
|
|
},
|
2020-10-28 02:04:32 +13:00
|
|
|
{
|
|
|
|
src: "node_modules/remixicon/fonts/*",
|
|
|
|
dest: outputpath,
|
|
|
|
},
|
2020-02-03 22:24:25 +13:00
|
|
|
],
|
|
|
|
}),
|
2019-07-13 21:35:57 +12:00
|
|
|
|
2020-03-05 05:47:47 +13:00
|
|
|
replace({
|
2020-03-28 05:58:32 +13:00
|
|
|
"process.env.NODE_ENV": JSON.stringify(
|
|
|
|
production ? "production" : "development"
|
|
|
|
),
|
2020-07-14 05:09:32 +12:00
|
|
|
"process.env.POSTHOG_TOKEN": JSON.stringify(process.env.POSTHOG_TOKEN),
|
2020-07-14 06:44:42 +12:00
|
|
|
"process.env.POSTHOG_URL": JSON.stringify(process.env.POSTHOG_URL),
|
2020-07-15 03:00:58 +12:00
|
|
|
"process.env.SENTRY_DSN": JSON.stringify(process.env.SENTRY_DSN),
|
2020-03-05 05:47:47 +13:00
|
|
|
}),
|
|
|
|
|
2020-02-03 22:24:25 +13:00
|
|
|
svelte({
|
|
|
|
// enable run-time checks when not in production
|
|
|
|
dev: !production,
|
2020-06-30 04:22:00 +12:00
|
|
|
include: [
|
|
|
|
"src/**/*.svelte",
|
|
|
|
"node_modules/**/*.svelte",
|
|
|
|
"../../../bbui/src/**/*.svelte",
|
|
|
|
],
|
2020-02-03 22:24:25 +13:00
|
|
|
// we'll extract any component CSS out into
|
|
|
|
// a separate file — better for performance
|
|
|
|
css: css => {
|
2020-11-10 07:04:55 +13:00
|
|
|
css.write("bundle.css")
|
2020-02-03 22:24:25 +13:00
|
|
|
},
|
|
|
|
}),
|
2019-07-13 21:35:57 +12:00
|
|
|
|
2020-09-10 03:27:46 +12:00
|
|
|
// export all CSS imported in the JS to it's own bundle
|
2020-09-09 23:06:04 +12:00
|
|
|
css({
|
2020-09-10 03:27:46 +12:00
|
|
|
output: `${outputpath}/external.css`,
|
2020-09-09 23:06:04 +12:00
|
|
|
}),
|
|
|
|
|
2020-02-03 22:24:25 +13:00
|
|
|
resolve({
|
|
|
|
browser: true,
|
|
|
|
dedupe: importee => {
|
|
|
|
return (
|
|
|
|
importee === "svelte" ||
|
|
|
|
importee.startsWith("svelte/") ||
|
|
|
|
coreExternal.includes(importee)
|
|
|
|
)
|
|
|
|
},
|
|
|
|
}),
|
2020-11-19 00:24:01 +13:00
|
|
|
commonjs(),
|
2020-02-03 22:24:25 +13:00
|
|
|
url({
|
|
|
|
limit: 0,
|
|
|
|
include: ["**/*.woff2", "**/*.png"],
|
|
|
|
fileName: "[dirname][name][extname]",
|
|
|
|
emitFiles: true,
|
|
|
|
}),
|
|
|
|
builtins(),
|
|
|
|
nodeglobals(),
|
2020-02-01 05:01:58 +13:00
|
|
|
|
2020-02-03 22:24:25 +13:00
|
|
|
// Watch the `dist` directory and refresh the
|
|
|
|
// browser on changes when not in production
|
2020-09-15 18:55:32 +12:00
|
|
|
!production && livereload({ watch: outputpath, delay: 500 }),
|
2019-07-13 21:35:57 +12:00
|
|
|
|
2020-02-03 22:24:25 +13:00
|
|
|
// If we're building for production (npm run build
|
|
|
|
// instead of npm run dev), minify
|
|
|
|
production && terser(),
|
2020-04-17 21:26:48 +12:00
|
|
|
json(),
|
2020-12-02 05:22:06 +13:00
|
|
|
html(),
|
2020-02-03 22:24:25 +13:00
|
|
|
],
|
2020-04-17 21:26:48 +12:00
|
|
|
}
|