1 | import * as path from 'path';
|
2 | import minify from 'rollup-plugin-babel-minify';
|
3 |
|
4 | import { nodeResolve } from '@rollup/plugin-node-resolve';
|
5 |
|
6 |
|
7 | const license = `/*
|
8 | Wombat.js client-side rewriting engine for web archive replay
|
9 | Copyright (C) 2014-${new Date().getFullYear()} Webrecorder Software, Rhizome, and Contributors. Released under the GNU Affero General Public License.
|
10 |
|
11 | This file is part of wombat.js, see https://github.com/webrecorder/wombat.js for the full source
|
12 | Wombat.js is part of the Webrecorder project (https://github.com/webrecorder)
|
13 |
|
14 | This program is free software: you can redistribute it and/or modify
|
15 | it under the terms of the GNU Affero General Public License as published
|
16 | by the Free Software Foundation, either version 3 of the License, or
|
17 | (at your option) any later version.
|
18 |
|
19 | This program is distributed in the hope that it will be useful,
|
20 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
22 | GNU Affero General Public License for more details.
|
23 |
|
24 | You should have received a copy of the GNU Affero General Public License
|
25 | along with this program. If not, see <https://www.gnu.org/licenses/>.
|
26 | */`
|
27 |
|
28 |
|
29 | const outputDir = process.env.OUTPUT_DIR || path.join(__dirname, 'dist');
|
30 |
|
31 | const addLicenceNoStrict = {
|
32 | renderChunk(code) {
|
33 | return `${license}\n${code.replace("'use strict';", '')}`;
|
34 | }
|
35 | };
|
36 |
|
37 | const minificationOpts = {
|
38 | booleans: false,
|
39 | builtIns: false,
|
40 | comments: false,
|
41 | deadcode: false,
|
42 | flipComparisons: false,
|
43 | infinity: false,
|
44 | keepClassName: true,
|
45 | keepFnName: true,
|
46 | mangle: false,
|
47 | removeUndefined: false,
|
48 | simplifyComparisons: false,
|
49 | sourceMap: false,
|
50 | typeConstructors: false,
|
51 | undefinedToVoid: false
|
52 | };
|
53 |
|
54 | export default [
|
55 | {
|
56 | input: 'src/wbWombat.js',
|
57 | plugins: [nodeResolve({ browser: true }), minify(minificationOpts), addLicenceNoStrict],
|
58 | output: {
|
59 | name: 'wombat',
|
60 | file: path.join(outputDir, 'wombat.js'),
|
61 | format: 'iife'
|
62 | }
|
63 | },
|
64 | {
|
65 | input: 'src/wbWombatProxyMode.js',
|
66 | plugins: [minify(minificationOpts), addLicenceNoStrict],
|
67 | output: {
|
68 | name: 'wombatProxyMode',
|
69 | file: path.join(outputDir, 'wombatProxyMode.js'),
|
70 | format: 'iife'
|
71 | }
|
72 | },
|
73 | {
|
74 | input: 'src/wombatWorkers.js',
|
75 | plugins: [minify(minificationOpts), addLicenceNoStrict],
|
76 | output: {
|
77 | name: 'wombatWorkers',
|
78 | file: path.join(outputDir, 'wombatWorkers.js'),
|
79 | format: 'es',
|
80 | sourcemap: false,
|
81 | exports: 'none'
|
82 | }
|
83 | },
|
84 | {
|
85 | input: 'src/autoFetchWorker.js',
|
86 | plugins: [
|
87 | {
|
88 | renderChunk(code) {
|
89 | if (!code.startsWith("'use strict';")) {
|
90 | return "'use strict';\n" + code;
|
91 | }
|
92 | return code;
|
93 | }
|
94 | }
|
95 | ],
|
96 | output: {
|
97 | name: 'autoFetchWorker',
|
98 | file: path.join(outputDir, 'autoFetchWorker.js'),
|
99 | format: 'es',
|
100 | sourcemap: false,
|
101 | exports: 'none'
|
102 | }
|
103 | }
|
104 | ];
|