-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrollup.config.js
47 lines (44 loc) · 1.24 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
// rollup.config.js
import resolve from 'rollup-plugin-node-resolve';
import replace from 'rollup-plugin-replace';
import commonjs from 'rollup-plugin-commonjs';
import hash from 'rollup-plugin-hash';
import builtins from 'rollup-plugin-node-builtins';
import { terser } from 'rollup-plugin-terser';
const INPUT_FILE = 'src/js/index.js';
const OUTPUT_FILE = '_site/js/index.js';
export default {
input: INPUT_FILE,
output: {
file: OUTPUT_FILE,
format: 'iife',
name: 'TechWeeklies',
},
plugins: [
// Replace calls to process.env with build-time variables
replace({
'process.env.NODE_ENV': JSON.stringify(
process.env.NODE_ENV || 'production'
),
'process.env.GA_TRACKING_ID': JSON.stringify(
process.env.GA_TRACKING_ID || ''
),
}),
// Resolve modules for bundling using node's search algorithtm
resolve(),
// Allow resolving CommonJS modules
commonjs(),
builtins(),
ifProduction(terser),
ifProduction(() =>
hash({
dest: '_site/js/index.[hash:10].js',
replace: true,
manifest: '_intermediate/rollup-manifest.json',
})
),
],
};
function ifProduction(plugin) {
return process.env.NODE_ENV === 'production' ? plugin() : null;
}