This repository was archived by the owner on Jan 29, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathrollup.config.js
More file actions
59 lines (54 loc) · 1.34 KB
/
Copy pathrollup.config.js
File metadata and controls
59 lines (54 loc) · 1.34 KB
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
import path from "path";
import TS from "rollup-plugin-typescript2";
import VuePlugin from "rollup-plugin-vue";
import { terser } from "rollup-plugin-terser";
const is_production = process.env.NODE_ENV === `production`;
const vtKebab = "vue-transmit";
const vtPascal = "VueTransmit";
const cssOut = path.join(__dirname, `dist/${vtKebab}.css`);
const vue_opts = { css: cssOut };
const ts_opts = { include: ["*.ts+(|x)", "**/*.ts+(|x)", RegExp(".*.ts?.*")] };
const plugins = [VuePlugin(vue_opts), TS({ clean: true, verbosity: 1 })];
export default [
{
input: "src/index.umd.ts",
output: {
format: "umd",
name: vtPascal,
file: `./dist/${vtKebab}.js`,
sourcemap: true,
globals: {
vue: "Vue",
firebase: "firebase",
},
},
},
{
input: path.resolve(__dirname, "src/index.ts"),
output: {
format: "es",
file: `./dist/${vtKebab}.esm.js`,
sourcemap: true,
},
},
].reduce((configs, { input, output }) => {
configs.push({
external: ["vue", "firebase"],
input,
output: { ...output },
plugins: plugins,
});
configs.push({
external: ["vue", "firebase"],
input,
output: {
...output,
file: replaceExtension(output.file, ".min.js"),
},
plugins: [...plugins, terser()],
});
return configs;
}, []);
function replaceExtension(name, replacement) {
return name.slice(0, name.lastIndexOf(".")) + replacement;
}