2019-07-13 11:35:57 +02: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';
|
|
|
|
import browsersync from "rollup-plugin-browsersync";
|
|
|
|
import proxy from "http-proxy-middleware";
|
|
|
|
|
2019-07-31 09:09:04 +02:00
|
|
|
const target = 'http://localhost:4001';
|
2019-07-15 07:59:46 +02:00
|
|
|
const _builderProxy = proxy('/_builder', {
|
|
|
|
target:"http://localhost:3000",
|
|
|
|
pathRewrite: {'^/_builder' : ''}
|
2019-07-13 11:35:57 +02:00
|
|
|
});
|
|
|
|
|
2019-09-09 06:23:41 +02:00
|
|
|
const apiProxy = proxy(['/_builder/api/**', '/_builder/**/componentlibrary'] , {
|
2019-07-15 07:59:46 +02:00
|
|
|
target,
|
|
|
|
logLevel: "debug",
|
|
|
|
changeOrigin: true,
|
|
|
|
cookieDomainRewrite: true,
|
|
|
|
onProxyReq(proxyReq) {
|
|
|
|
if (proxyReq.getHeader("origin")) {
|
|
|
|
proxyReq.setHeader("origin", target)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-07-13 11:35:57 +02:00
|
|
|
const production = !process.env.ROLLUP_WATCH;
|
|
|
|
|
|
|
|
const lodash_fp_exports = ["union", "reduce", "isUndefined", "cloneDeep", "split", "some", "map", "filter", "isEmpty", "countBy", "includes", "last", "find", "constant",
|
|
|
|
"take", "first", "intersection", "mapValues", "isNull", "has", "isNumber", "isString", "isBoolean", "isDate", "isArray", "isObject", "clone", "values", "keyBy",
|
|
|
|
"keys", "orderBy", "concat", "reverse", "difference", "merge", "flatten", "each", "pull", "join", "defaultCase", "uniqBy", "every", "uniqWith", "isFunction", "groupBy",
|
2019-09-20 09:01:35 +02:00
|
|
|
"differenceBy", "intersectionBy", "isEqual", "max", "sortBy", "assign", "uniq", "trimChars", "trimCharsStart", "isObjectLike", "flattenDeep", "indexOf", "isPlainObject"];
|
2019-07-13 11:35:57 +02:00
|
|
|
|
|
|
|
const lodash_exports = ["toNumber", "flow", "isArray", "join", "replace", "trim", "dropRight", "takeRight", "head", "isUndefined", "isNull", "isNaN", "reduce", "isEmpty",
|
|
|
|
"constant", "tail", "includes", "startsWith", "findIndex", "isInteger", "isDate", "isString", "split", "clone", "keys", "isFunction", "merge", "has", "isBoolean", "isNumber",
|
|
|
|
"isObjectLike", "assign", "some", "each", "find", "orderBy", "union", "cloneDeep"];
|
|
|
|
|
2019-07-15 07:59:46 +02:00
|
|
|
const outputpath = "../server/builder";
|
2019-07-13 11:35:57 +02:00
|
|
|
|
2019-07-30 10:08:40 +02:00
|
|
|
const coreExternal = [
|
|
|
|
"lodash", "lodash/fp", "date-fns",
|
|
|
|
"lunr", "safe-buffer", "shortid",
|
|
|
|
"@nx-js/compiler-util"
|
|
|
|
];
|
|
|
|
|
2019-07-13 11:35:57 +02:00
|
|
|
export default {
|
|
|
|
input: 'src/main.js',
|
|
|
|
output: {
|
|
|
|
sourcemap: true,
|
|
|
|
format: 'iife',
|
|
|
|
name: 'app',
|
2019-07-30 10:08:40 +02:00
|
|
|
file: `${outputpath}/bundle.js`
|
2019-07-13 11:35:57 +02:00
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
copy({
|
|
|
|
targets: [
|
2019-07-15 07:59:46 +02:00
|
|
|
{ src: 'src/index.html', dest: outputpath },
|
|
|
|
{ src: 'src/favicon.png', dest: outputpath }
|
2019-07-13 11:35:57 +02:00
|
|
|
]
|
|
|
|
}),
|
|
|
|
|
|
|
|
svelte({
|
|
|
|
// enable run-time checks when not in production
|
|
|
|
dev: !production,
|
|
|
|
include: 'src/**/*.svelte',
|
|
|
|
// we'll extract any component CSS out into
|
|
|
|
// a separate file — better for performance
|
|
|
|
css: css => {
|
2019-07-15 07:59:46 +02:00
|
|
|
css.write(`${outputpath}/bundle.css`);
|
2019-07-13 11:35:57 +02:00
|
|
|
}
|
|
|
|
}),
|
|
|
|
|
|
|
|
resolve({
|
|
|
|
browser: true,
|
2019-07-30 10:08:40 +02:00
|
|
|
dedupe: importee => {
|
|
|
|
return importee === 'svelte'
|
|
|
|
|| importee.startsWith('svelte/')
|
|
|
|
|| coreExternal.includes(importee);
|
|
|
|
}
|
2019-07-13 11:35:57 +02:00
|
|
|
|
|
|
|
}),
|
|
|
|
commonjs({
|
|
|
|
namedExports: {
|
|
|
|
"lodash/fp": lodash_fp_exports,
|
|
|
|
"lodash":lodash_exports,
|
|
|
|
"shortid": ["generate"]
|
2019-07-30 10:08:40 +02:00
|
|
|
}
|
2019-07-13 11:35:57 +02:00
|
|
|
}),
|
|
|
|
url({
|
|
|
|
limit: 0,
|
|
|
|
include: ["**/*.woff2", "**/*.png"],
|
|
|
|
fileName: "[dirname][name][extname]",
|
|
|
|
emitFiles: true
|
|
|
|
}),
|
|
|
|
url({
|
|
|
|
limit: 0,
|
|
|
|
include: ["**/*.css"],
|
|
|
|
fileName: "[name][extname]",
|
|
|
|
emitFiles: true
|
|
|
|
}),
|
|
|
|
builtins(),
|
|
|
|
nodeglobals(),
|
|
|
|
|
|
|
|
// Watch the `dist` directory and refresh the
|
|
|
|
// browser on changes when not in production
|
2019-07-15 07:59:46 +02:00
|
|
|
!production && livereload(outputpath),
|
2019-07-13 11:35:57 +02:00
|
|
|
!production && browsersync({
|
2019-07-15 07:59:46 +02:00
|
|
|
server: outputpath,
|
2019-07-31 09:09:04 +02:00
|
|
|
middleware: [apiProxy,_builderProxy]
|
2019-07-13 11:35:57 +02:00
|
|
|
}),
|
|
|
|
|
|
|
|
// If we're building for production (npm run build
|
|
|
|
// instead of npm run dev), minify
|
|
|
|
production && terser()
|
|
|
|
],
|
|
|
|
watch: {
|
|
|
|
clearScreen: false
|
|
|
|
}
|
|
|
|
};
|