-
Notifications
You must be signed in to change notification settings - Fork 22
/
rollup.common.config.js
95 lines (90 loc) · 2.25 KB
/
rollup.common.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/* eslint-disable no-console */
import autoPreprocess from "svelte-preprocess";
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import livereload from "rollup-plugin-livereload";
import replace from "@rollup/plugin-replace";
import json from "@rollup/plugin-json";
import alias from "@rollup/plugin-alias";
import istanbul from "rollup-plugin-istanbul";
import path from "path";
import dotenv from "dotenv";
import esbuild from "rollup-plugin-esbuild";
const ROOT = "../..";
dotenv.config({ path: path.resolve(ROOT, ".env") });
export const production =
process.env.NODE_ENV !== "development" && !process.env.ROLLUP_WATCH;
const config = {
output: {
sourcemap: "inline",
format: "umd",
name: "app",
file: "index.js",
},
plugins: [
resolve({
extensions: [".ts", ".js", ".json"],
browser: true,
dedupe: ["svelte"],
}),
replace({
"process.env.API_GATEWAY": `'${process.env.API_GATEWAY}'`,
"process.env.NODE_ENV": process.env.NODE_ENV
? `'${process.env.NODE_ENV}'`
: '"development"',
}),
alias({
resolve: [".js", ".scss", ".svelte", ".scss", ".ts"],
entries: [
{
find: "@commons",
replacement: path.resolve(`${ROOT}/commons/src`),
},
],
}),
esbuild({
include: [`${ROOT}/**/*.ts+(|x)`],
minify: !!production,
}),
commonjs(),
json(),
!production &&
istanbul({
extensions: [".js", ".svelte"],
include: ["components/**/*"],
exclude: ["**/*spec.js", "node_modules"],
sourceMap: true,
compact: false,
debug: true,
}),
],
watch: {
clearScreen: false,
},
};
if (process.env.ROLLUP_WATCH) {
config.plugins.push(
livereload({
watch: "index.js",
port: (() => {
const port = 1024 + Math.floor(Math.random() * 48127);
console.log("Using port for livereload:", port);
return port;
})(),
}),
);
}
export default config;
export const svelteConfig = {
dev: !production,
preprocess: autoPreprocess({
scss: {
includePaths: [`${ROOT}/node_modules`],
},
}),
emitCss: false,
compilerOptions: {
dev: !production,
customElement: true,
},
};