-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
136 lines (130 loc) · 3.52 KB
/
rollup.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import externals from "rollup-plugin-node-externals";
import inject from "@rollup/plugin-inject";
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import graphql from "@rollup/plugin-graphql";
import typescript from "rollup-plugin-typescript2";
import copy from "rollup-plugin-copy";
import postcss from "rollup-plugin-postcss";
import json from "@rollup/plugin-json";
import analyze from "rollup-plugin-analyzer";
import generatePackageJson from "rollup-plugin-generate-package-json";
import autoprefixer from "autoprefixer";
const ANALYZE = false;
const analyzeFilter = ({ id }) => !id.startsWith("/node_modules");
const pkg = require("./package.json");
const reactPkg = `${pkg.name}-react`;
const serverPkg = `${pkg.name}-server`;
const bundleESModules = "react-linkify-it";
export default [
{
input: "src/index.graphql.ts",
output: [
{
file: `${serverPkg}/index.js`,
format: "cjs",
sourcemap: true,
},
],
plugins: [
externals({ exclude: bundleESModules }),
typescript(),
json(),
graphql(),
resolve(),
commonjs(),
generatePackageJson({
baseContents: {
name: serverPkg,
description:
"GraphQL resolvers and DB client for OpenAP Inventory Manager",
bin: pkg.bin,
license: pkg.license,
version: pkg.version,
author: pkg.author,
repository: pkg.repository,
private: pkg.private,
main: "index.js",
types: "index.graphql.d.ts",
peerDependencies: pkg.peerDependenciesServer,
directories: {
migrations: "migrations",
public: "public",
},
},
additionalDependencies: {
"node-pg-migrate": pkg.dependencies["node-pg-migrate"],
},
}),
copy({
targets: [
{ src: ["bin", "migrations", "public", "LICENSE"], dest: serverPkg },
{ src: "README-SERVER.md", dest: serverPkg, rename: "README.md" },
],
}),
ANALYZE &&
analyze({
filter: analyzeFilter,
}),
],
},
{
input: "src/index.app.ts",
output: [
{
file: `${reactPkg}/index.js`,
format: "cjs",
sourcemap: true,
},
],
plugins: [
externals({ exclude: bundleESModules }),
typescript({
outDir: "app",
}),
json(),
graphql(),
resolve({
browser: true,
preferBuiltins: false,
}),
commonjs(),
inject({
window: "global/window",
}),
postcss({
extract: false,
modules: true,
namedExports: true,
sourceMap: true,
plugins: [autoprefixer()],
}),
generatePackageJson({
baseContents: {
name: reactPkg,
description: "React UI for OpenAP Inventory Manager",
peerDependencies: pkg.peerDependenciesClient,
repository: pkg.repository,
private: pkg.private,
license: pkg.license,
version: pkg.version,
author: pkg.author,
main: "index.js",
types: "index.app.d.ts",
},
}),
copy({
targets: [
{ src: ["src/app/**/*.css", "LICENSE"], dest: reactPkg },
{ src: "README-REACT.md", dest: reactPkg, rename: "README.md" },
],
flatten: false,
}),
ANALYZE &&
analyze({
showExports: true,
filter: analyzeFilter,
}),
],
},
];