-
-
Notifications
You must be signed in to change notification settings - Fork 152
/
Copy pathrollup.config.js
57 lines (53 loc) · 1.36 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
import {nodeResolve} from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import license from 'rollup-plugin-license';
import {globby} from 'globby';
import {createTag, replaceResultTransformer} from 'common-tags';
import {delete_comments as deleteComments} from 'delete_comments';
import {defineConfig} from 'rollup';
/** Matches empty lines: https://stackoverflow.com/q/16369642/10292952 */
const emptyLineRegex = /^\s*[\r\n]/gm;
const stripComments = createTag(
{onEndResult: deleteComments},
replaceResultTransformer(emptyLineRegex, ''),
);
const outputDirectory = 'build';
export default defineConfig({
input: await globby('source/**/*.js'),
output: {
dir: outputDirectory,
interop: 'esModule',
generatedCode: {
preset: 'es2015',
},
chunkFileNames: '[name].js',
manualChunks(id) {
if (id.includes('node_modules')) {
return 'dependencies';
}
},
hoistTransitiveImports: false,
plugins: [{
name: 'strip-dependency-comments',
renderChunk(code, chunk) {
return chunk.name === 'dependencies' ? stripComments(code) : null;
},
}],
},
treeshake: {
moduleSideEffects: 'no-external',
},
plugins: [
nodeResolve(),
commonjs({
include: 'node_modules/**',
}),
json(),
license({
thirdParty: {
output: `${outputDirectory}/licenses.md`,
},
}),
],
});