-
Notifications
You must be signed in to change notification settings - Fork 0
/
.rollup.js
50 lines (45 loc) · 1.28 KB
/
.rollup.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
import { babel } from '@rollup/plugin-babel';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import { resolve } from 'path';
import html from 'rollup-plugin-html';
import typescript from 'rollup-plugin-typescript2';
const extensions = ['.ts', '.js'];
const preventTreeShakingPlugin = {
name: 'no-threeshaking',
resolveId: (id, importer) => (importer ? null : { id, moduleSideEffects: 'no-treeshake' }),
};
const isGithub = process.env.ENV === 'GITHUB';
const minifiedJs = {
comments: false,
compact: true,
minified: true,
};
const minifiedHtml = {
collapseWhitespace: true,
collapseBooleanAttributes: true,
conservativeCollapse: true,
minifyJS: true,
};
/** @type {import('rollup').RollupOptions} */
const config = {
input: './.build/index.ts',
output: { dir: '.build', format: 'esm' },
plugins: [
preventTreeShakingPlugin,
nodeResolve({ extensions }),
html({
include: ['./src/views/*.html', './.build/views/*.html'],
...(isGithub ? minifiedHtml : {}),
}),
typescript(),
babel({
extensions,
babelHelpers: 'runtime',
include: resolve('.build', 'src', '**', '*.ts'),
exclude: ['node_modules/**'],
configFile: './.babelrc.js',
...(isGithub ? minifiedJs : {}),
}),
],
};
export default config;