forked from ceph/ceph.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
67 lines (61 loc) · 1.64 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
import { nodeResolve as resolve } from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import babel from '@rollup/plugin-babel';
import { terser } from 'rollup-plugin-terser';
const srcDir = `./src/js/`;
const distDir = 'dist/js/';
const commonjsOptions = {
dynamicRequireTargets: [
'./src/_11ty/filters/cleanCardContent.js',
'./src/_11ty/filters/formatDate.js',
'./src/_11ty/filters/getSingleDigitFromDate.js',
'./src/_11ty/filters/truncate.js',
'./src/_11ty/shortcodes/ArticleCard.js',
],
transformMixedEsModules: true,
};
const pluginsES = () => [
resolve(),
commonjs(commonjsOptions),
process.env.NODE_ENV === 'production'
? terser({ output: { comments: false } })
: null,
];
const pluginsES5 = () => [
resolve(),
commonjs(commonjsOptions),
babel({
babelHelpers: 'bundled',
exclude: 'node_modules/**',
presets: [
[
'@babel/preset-env',
{
targets: {
browsers: ['ie 11'],
},
useBuiltIns: 'usage',
corejs: 3,
},
],
],
}),
process.env.NODE_ENV === 'production' && terser(),
];
function setupBuild(plugins, src, dist) {
return {
input: srcDir + src,
output: {
file: distDir + dist,
format: 'iife',
sourcemap: process.env.NODE_ENV === 'production' ? false : 'inline',
},
plugins: plugins,
};
}
export default [
setupBuild(pluginsES(), 'main.js', 'bundle-main.mjs'),
setupBuild(pluginsES5(), 'main.js', 'bundle-main.js'),
setupBuild(pluginsES(), 'search.js', 'bundle-search.mjs'),
setupBuild(pluginsES5(), 'search.js', 'bundle-search.js'),
];