-
Notifications
You must be signed in to change notification settings - Fork 31
/
rollup-build.config.ts
110 lines (102 loc) · 2.16 KB
/
rollup-build.config.ts
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
import {clean, importStyles, minifyLitHTML} from "@appnest/web-config";
import ts from '@wessberg/rollup-plugin-ts';
import autoprefixer from 'autoprefixer';
import cssnano from 'cssnano';
import path from 'path';
import precss from 'precss';
import commonjs from 'rollup-plugin-commonjs';
import resolve from 'rollup-plugin-node-resolve';
import progress from 'rollup-plugin-progress';
import {terser} from 'rollup-plugin-terser';
import pkg from "./package.json";
const folders = {
src: path.resolve(__dirname, "src/lib"),
dist: path.resolve(__dirname, "dist"),
dist_umd: path.resolve(__dirname, "dist/umd"),
};
const files = {
src_index: path.join(folders.src, "index.ts"),
dist_umd_weightless: path.join(folders.dist_umd, "weightless.min.js")
};
const plugins = ({tsConfig} = {}) => [
progress(),
resolve(),
importStyles({
plugins: [
precss(),
autoprefixer(),
cssnano({
preset: ["default", {
calc: false
}]
})
]
}),
// Teaches Rollup how to transpile Typescript
// https://github.com/wessberg/rollup-plugin-ts
ts(tsConfig || {}),
// At the moment, the majority of packages on NPM are exposed as CommonJS modules
commonjs({
include: "**/node_modules/**",
}),
minifyLitHTML({
verbose: false
})
];
const configs = [
{
input: files.src_index,
output: [
{
format: "esm",
dir: folders.dist
}
],
treeshake: false,
preserveModules: true,
plugins: [
clean({
targets: [
folders.dist
]
}),
...plugins({
tsConfig: {
transpiler: "typescript",
tsconfig: "tsconfig.build.json",
exclude: ["node_modules/**/*.*"],
browserslist: false,
}
})
],
external: [
...Object.keys(pkg.dependencies),
...Object.keys(pkg.devDependencies),
"@a11y/focus-trap/debounce",
"lit-html/directives/if-defined",
"tslib"
]
},
{
input: files.src_index,
output: [
{
format: "umd",
name: "weightless",
file: files.dist_umd_weightless,
banner: `/** weightless v${pkg.version} **/`
}
],
treeshake: true,
plugins: [
...plugins(),
terser({
output: {
comments: /.*weightless v.*/
}
})
],
context: "window"
}
];
export default configs;