-
Notifications
You must be signed in to change notification settings - Fork 18
/
rollup.config.mjs
124 lines (122 loc) · 3.72 KB
/
rollup.config.mjs
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// Rollup plugins
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import copy from 'rollup-plugin-copy';
import { minifyHTML } from 'rollup-plugin-minify-html';
import nodePolyfills from 'rollup-plugin-polyfill-node';
import postcss from 'rollup-plugin-postcss';
import { defineRollupSwcOption, swc } from 'rollup-plugin-swc3';
const production = process.env.NODE_ENV === 'production';
console.log('Package mode:', production ? 'production' : 'development');
export default [
{
input: './lana/src/Main.ts',
output: {
format: 'cjs',
dir: './lana/out',
chunkFileNames: 'lana-[name].js',
sourcemap: false,
},
external: ['vscode'],
plugins: [
nodeResolve({ preferBuiltins: true, dedupe: ['@salesforce/core'] }),
commonjs(),
json(),
swc(
defineRollupSwcOption({
include: /\.[mc]?[jt]sx?$/,
exclude: 'node_modules',
tsconfig: production ? './lana/tsconfig.json' : './lana/tsconfig-dev.json',
jsc: {
minify: {
compress: production,
mangle: production
? {
keep_classnames: true,
}
: false,
},
},
}),
),
],
},
{
input: { bundle: './log-viewer/modules/Main.ts' },
output: [
{
format: 'es',
dir: './log-viewer/out',
chunkFileNames: 'log-viewer-[name].js',
sourcemap: false,
},
],
plugins: [
nodeResolve({ browser: true, preferBuiltins: false }),
commonjs(),
nodePolyfills(),
swc(
defineRollupSwcOption({
// All options are optional
include: /\.[mc]?[jt]sx?$/,
exclude: 'node_modules',
tsconfig: production ? './log-viewer/tsconfig.json' : './log-viewer/tsconfig-dev.json',
jsc: {
transform: { useDefineForClassFields: false },
minify: {
compress: production,
mangle: production
? {
keep_classnames: true,
}
: false,
},
},
}),
),
postcss({
extensions: ['.css', '.scss'],
minimize: true,
}),
minifyHTML({
targets: [
{
src: './log-viewer/index.html',
dest: './log-viewer/out/index.html',
minifierOptions: production
? {
collapseWhitespace: true,
html5: true,
includeAutoGeneratedTags: false,
minifyCSS: true,
preventAttributesEscaping: true,
processConditionalComments: true,
removeAttributeQuotes: false,
removeComments: true,
removeEmptyAttributes: false,
removeOptionalTags: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
sortAttributes: true,
sortClassName: true,
trimCustomFragments: true,
useShortDoctype: true,
}
: {},
},
],
}),
copy({
hook: 'closeBundle',
targets: [
{ src: 'log-viewer/out/*', dest: 'lana/out' },
{ src: ['CHANGELOG.md', 'LICENSE.txt', 'README.md'], dest: 'lana' },
{ src: 'lana/certinia-icon-color.png', dest: 'lana/out' },
{ src: 'node_modules/@vscode/codicons/dist/codicon.ttf', dest: 'lana/out' },
],
}),
],
},
];