2020-04-01 12:38:07 +02:00
|
|
|
import alias from "@rollup/plugin-alias"
|
2020-02-03 10:24:25 +01:00
|
|
|
import svelte from "rollup-plugin-svelte"
|
|
|
|
import resolve from "rollup-plugin-node-resolve"
|
|
|
|
import commonjs from "rollup-plugin-commonjs"
|
|
|
|
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-03-04 17:47:47 +01:00
|
|
|
import replace from "rollup-plugin-replace"
|
2020-04-17 11:26:48 +02:00
|
|
|
import json from '@rollup/plugin-json';
|
|
|
|
|
2019-07-13 11:35:57 +02:00
|
|
|
|
2020-04-01 12:38:07 +02:00
|
|
|
import path from "path"
|
|
|
|
|
2020-02-03 10:24:25 +01:00
|
|
|
const production = !process.env.ROLLUP_WATCH
|
2019-07-13 11:35:57 +02:00
|
|
|
|
2020-02-03 10:24:25 +01:00
|
|
|
const lodash_fp_exports = [
|
2020-04-29 21:29:42 +02:00
|
|
|
"pipe",
|
2020-02-03 10:24:25 +01:00
|
|
|
"union",
|
|
|
|
"reduce",
|
|
|
|
"isUndefined",
|
|
|
|
"cloneDeep",
|
|
|
|
"split",
|
|
|
|
"some",
|
|
|
|
"map",
|
|
|
|
"filter",
|
|
|
|
"isEmpty",
|
|
|
|
"countBy",
|
|
|
|
"includes",
|
|
|
|
"last",
|
|
|
|
"find",
|
|
|
|
"constant",
|
|
|
|
"take",
|
|
|
|
"first",
|
|
|
|
"intersection",
|
|
|
|
"mapValues",
|
|
|
|
"isNull",
|
|
|
|
"has",
|
|
|
|
"isInteger",
|
|
|
|
"isNumber",
|
|
|
|
"isString",
|
|
|
|
"isBoolean",
|
|
|
|
"isDate",
|
|
|
|
"isArray",
|
|
|
|
"isObject",
|
|
|
|
"clone",
|
|
|
|
"values",
|
|
|
|
"keyBy",
|
|
|
|
"isNaN",
|
|
|
|
"keys",
|
|
|
|
"orderBy",
|
|
|
|
"concat",
|
|
|
|
"reverse",
|
|
|
|
"difference",
|
|
|
|
"merge",
|
|
|
|
"flatten",
|
|
|
|
"each",
|
|
|
|
"pull",
|
|
|
|
"join",
|
|
|
|
"defaultCase",
|
|
|
|
"uniqBy",
|
|
|
|
"every",
|
|
|
|
"uniqWith",
|
|
|
|
"isFunction",
|
|
|
|
"groupBy",
|
|
|
|
"differenceBy",
|
|
|
|
"intersectionBy",
|
|
|
|
"isEqual",
|
|
|
|
"max",
|
|
|
|
"sortBy",
|
|
|
|
"assign",
|
|
|
|
"uniq",
|
|
|
|
"trimChars",
|
|
|
|
"trimCharsStart",
|
|
|
|
"isObjectLike",
|
|
|
|
"flattenDeep",
|
|
|
|
"indexOf",
|
|
|
|
"isPlainObject",
|
|
|
|
"toNumber",
|
|
|
|
"takeRight",
|
|
|
|
"toPairs",
|
2020-03-22 10:21:18 +01:00
|
|
|
"remove",
|
|
|
|
"findIndex",
|
2020-03-24 12:35:46 +01:00
|
|
|
"compose",
|
|
|
|
"get",
|
2020-03-27 17:58:32 +01:00
|
|
|
"tap",
|
2020-02-03 10:24:25 +01:00
|
|
|
]
|
2019-07-13 11:35:57 +02:00
|
|
|
|
2020-02-03 10:24:25 +01:00
|
|
|
const lodash_exports = [
|
|
|
|
"flow",
|
|
|
|
"join",
|
|
|
|
"replace",
|
|
|
|
"trim",
|
|
|
|
"dropRight",
|
|
|
|
"takeRight",
|
|
|
|
"head",
|
|
|
|
"reduce",
|
|
|
|
"tail",
|
|
|
|
"startsWith",
|
|
|
|
"findIndex",
|
|
|
|
"merge",
|
|
|
|
"assign",
|
|
|
|
"each",
|
|
|
|
"find",
|
|
|
|
"orderBy",
|
|
|
|
"union",
|
|
|
|
]
|
2019-07-13 11:35:57 +02:00
|
|
|
|
2020-02-03 10:24:25 +01:00
|
|
|
const outputpath = "../server/builder"
|
2019-07-13 11:35:57 +02:00
|
|
|
|
2019-07-30 10:08:40 +02:00
|
|
|
const coreExternal = [
|
2020-02-03 10:24:25 +01:00
|
|
|
"lodash",
|
|
|
|
"lodash/fp",
|
|
|
|
"date-fns",
|
|
|
|
"lunr",
|
|
|
|
"safe-buffer",
|
|
|
|
"shortid",
|
|
|
|
"@nx-js/compiler-util",
|
|
|
|
]
|
2019-07-30 10:08:40 +02:00
|
|
|
|
2020-04-01 12:38:07 +02:00
|
|
|
const customResolver = resolve({
|
2020-04-20 17:17:11 +02:00
|
|
|
extensions: [".mjs", ".js", ".jsx", ".json", ".sass", ".scss", ".svelte", ".css"]
|
2020-04-01 12:38:07 +02:00
|
|
|
})
|
|
|
|
const projectRootDir = path.resolve(__dirname)
|
|
|
|
|
2019-07-13 11:35:57 +02:00
|
|
|
export default {
|
2020-02-03 10:24:25 +01:00
|
|
|
input: "src/main.js",
|
|
|
|
output: {
|
|
|
|
sourcemap: true,
|
|
|
|
format: "iife",
|
|
|
|
name: "app",
|
|
|
|
file: `${outputpath}/bundle.js`,
|
|
|
|
},
|
|
|
|
plugins: [
|
2020-04-01 12:38:07 +02:00
|
|
|
alias({
|
|
|
|
entries: [
|
2020-04-17 11:26:48 +02:00
|
|
|
{
|
|
|
|
find: "components",
|
|
|
|
replacement: path.resolve(projectRootDir, "src/components"),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
find: "builderStore",
|
|
|
|
replacement: path.resolve(projectRootDir, "src/builderStore"),
|
|
|
|
},
|
2020-04-01 12:38:07 +02:00
|
|
|
],
|
2020-04-17 11:26:48 +02:00
|
|
|
customResolver,
|
2020-04-01 12:38:07 +02:00
|
|
|
}),
|
2020-02-03 10:24:25 +01:00
|
|
|
copy({
|
|
|
|
targets: [
|
2020-04-02 11:44:42 +02:00
|
|
|
{ src: "src/index.html", dest: outputpath },
|
2020-02-03 10:24:25 +01:00
|
|
|
{ src: "src/favicon.png", dest: outputpath },
|
2020-05-06 11:33:30 +02:00
|
|
|
{ src: "assets", dest: outputpath },
|
2020-02-03 10:24:25 +01:00
|
|
|
{
|
|
|
|
src: "node_modules/@budibase/client/dist/budibase-client.esm.mjs",
|
|
|
|
dest: outputpath,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}),
|
2019-07-13 11:35:57 +02:00
|
|
|
|
2020-03-04 17:47:47 +01:00
|
|
|
replace({
|
2020-03-27 17:58:32 +01:00
|
|
|
"process.env.NODE_ENV": JSON.stringify(
|
|
|
|
production ? "production" : "development"
|
|
|
|
),
|
2020-03-04 17:47:47 +01:00
|
|
|
}),
|
|
|
|
|
2020-02-03 10:24:25 +01:00
|
|
|
svelte({
|
|
|
|
// enable run-time checks when not in production
|
|
|
|
dev: !production,
|
2020-03-12 15:23:29 +01:00
|
|
|
include: ["src/**/*.svelte", "node_modules/**/*.svelte"],
|
2020-02-03 10:24:25 +01:00
|
|
|
// we'll extract any component CSS out into
|
|
|
|
// a separate file — better for performance
|
|
|
|
css: css => {
|
|
|
|
css.write(`${outputpath}/bundle.css`)
|
|
|
|
},
|
|
|
|
}),
|
2019-07-13 11:35:57 +02:00
|
|
|
|
2020-02-03 10:24:25 +01:00
|
|
|
resolve({
|
|
|
|
browser: true,
|
|
|
|
dedupe: importee => {
|
|
|
|
return (
|
|
|
|
importee === "svelte" ||
|
|
|
|
importee.startsWith("svelte/") ||
|
|
|
|
coreExternal.includes(importee)
|
|
|
|
)
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
commonjs({
|
|
|
|
namedExports: {
|
|
|
|
"lodash/fp": lodash_fp_exports,
|
|
|
|
lodash: lodash_exports,
|
|
|
|
shortid: ["generate"],
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
url({
|
|
|
|
limit: 0,
|
|
|
|
include: ["**/*.woff2", "**/*.png"],
|
|
|
|
fileName: "[dirname][name][extname]",
|
|
|
|
emitFiles: true,
|
|
|
|
}),
|
|
|
|
url({
|
|
|
|
limit: 0,
|
|
|
|
include: ["**/*.css"],
|
|
|
|
fileName: "[name][extname]",
|
|
|
|
emitFiles: true,
|
|
|
|
}),
|
|
|
|
builtins(),
|
|
|
|
nodeglobals(),
|
2020-01-31 17:01:58 +01:00
|
|
|
|
2020-02-03 10:24:25 +01:00
|
|
|
// Watch the `dist` directory and refresh the
|
|
|
|
// browser on changes when not in production
|
|
|
|
!production && livereload(outputpath),
|
2019-07-13 11:35:57 +02:00
|
|
|
|
2020-02-03 10:24:25 +01:00
|
|
|
// If we're building for production (npm run build
|
|
|
|
// instead of npm run dev), minify
|
|
|
|
production && terser(),
|
2020-04-17 11:26:48 +02:00
|
|
|
json(),
|
2020-02-03 10:24:25 +01:00
|
|
|
],
|
2020-04-17 11:26:48 +02:00
|
|
|
}
|