-
Notifications
You must be signed in to change notification settings - Fork 1
/
rollup.config.js
103 lines (98 loc) · 2.38 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
import plugin_globals from "rollup-plugin-node-globals";
import builtins from "rollup-plugin-node-builtins";
import babel from "rollup-plugin-babel";
import commonjs from "rollup-plugin-commonjs";
import minify from "rollup-plugin-babel-minify";
import resolve from "rollup-plugin-node-resolve";
import vue from "rollup-plugin-vue2";
import postcss from "rollup-plugin-postcss";
import css from "rollup-plugin-css-only";
import image from "rollup-plugin-img";
import pkg from "./package.json";
const LIBRARY_NAME = "PDFView";
const FILE_NAME = "vue-pdfjs-viewer";
const externals = [
...(pkg.dependencies ? Object.keys(pkg.dependencies) : []),
...(pkg.peerDependencies ? Object.keys(pkg.peerDependencies) : []),
"pdfjs-dist/build/pdf.js",
];
const externalExcludes = [];
const sourcemap = false;
const plugins = [
resolve({
browser: true,
preferBuiltins: true,
}),
vue({ css: false }),
commonjs({
namedExports: {
"node_modules/pdfjs-dist/build/pdf.js": ["pdfjs"],
},
}),
babel({
runtimeHelpers: true,
exclude: "node_modules/**",
babelrc: true,
extensions: [".js", ".jsx", ".es6", ".es", ".mjs", ".vue"],
}),
postcss({
extensions: [".css, .scss"],
namedExports: true,
}),
css({
output: false,
}),
plugin_globals(),
builtins(),
image({
output: `dist/images`, // default the root
extensions: /\.(png|jpg|jpeg|gif|svg)$/, // support png|jpg|jpeg|gif|svg, and it's alse the default value
limit: 50000, // default 8192(8k)
exclude: "node_modules/**",
}),
];
const defaultConfig = {
input: "src/index.js",
external: externals.filter((dep) => {
return !externalExcludes.includes(dep);
}),
};
export default [
{
...defaultConfig,
output: [
{
file: `dist/${FILE_NAME}.es.js`,
format: "es",
sourcemap,
exports: "named",
},
{
file: `dist/${FILE_NAME}.umd.js`,
format: "umd",
name: LIBRARY_NAME,
sourcemap,
exports: "named",
},
{
file: `dist/${FILE_NAME}.js`,
format: "iife",
name: LIBRARY_NAME,
sourcemap,
exports: "named",
},
],
plugins,
},
{
...defaultConfig,
output: {
file: `dist/${FILE_NAME}.min.js`,
format: "iife",
name: LIBRARY_NAME,
sourcemap,
exports: "named",
},
plugins: [...plugins, minify()],
},
];