-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup.config.js
More file actions
78 lines (73 loc) · 1.89 KB
/
rollup.config.js
File metadata and controls
78 lines (73 loc) · 1.89 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import { getBabelOutputPlugin } from "@rollup/plugin-babel";
import terser from "@rollup/plugin-terser";
import path from "path";
import analyze from "rollup-plugin-analyzer";
import gzipPlugin from "rollup-plugin-gzip";
import includePaths from "rollup-plugin-includepaths";
import typescript from "@rollup/plugin-typescript";
const INCLUDED_FILE_EXTENSIONS = [".js", ".ts"];
const JS_ROOT = "./src";
const INPUT_FILE = "index.ts";
const NAME = "typewriter";
const inputFilePath = path.join(JS_ROOT, INPUT_FILE);
const isProduction = process.env.NODE_ENV === "production";
const includePathOptions = {
paths: [JS_ROOT],
extensions: INCLUDED_FILE_EXTENSIONS,
};
const outputPlugins = [
isProduction && terser(),
isProduction && gzipPlugin(),
].filter(Boolean);
/**
* @type {import('rollup').RollupOptions}
*/
const config = {
input: inputFilePath,
treeshake: "recommended",
plugins: [
includePaths(includePathOptions),
typescript({ tsconfig: "./tsconfig.json" }),
!isProduction && analyze({ summaryOnly: true }),
],
output: [
{
file: `dist/${NAME}-babel-iife.js`,
format: "iife",
plugins: [
...outputPlugins,
getBabelOutputPlugin({
presets: ["@babel/preset-env"],
allowAllFormats: true,
}),
],
sourcemap: true,
name: NAME[0].toUpperCase() + NAME.slice(1),
},
{
file: `dist/${NAME}-babel.mjs`,
format: "es",
plugins: [
...outputPlugins,
getBabelOutputPlugin({
presets: ["@babel/preset-env"],
}),
],
sourcemap: true,
},
{
file: `dist/${NAME}-iife.js`,
format: "iife",
plugins: outputPlugins,
sourcemap: true,
name: NAME[0].toUpperCase() + NAME.slice(1),
},
{
file: `dist/${NAME}.mjs`,
format: "es",
plugins: outputPlugins,
sourcemap: true,
},
],
};
export default config;