-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
rollup.config.mjs
76 lines (73 loc) · 2.02 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
import { defineConfig } from 'rollup';
import terser from "@rollup/plugin-terser";
import postcssCombineDuplicatedSelectors from 'postcss-combine-duplicated-selectors';
import cssnanoPlugin from 'cssnano';
import postcss from 'rollup-plugin-postcss';
import eslint from '@rollup/plugin-eslint';
import pkg from './package.json' with { type: "json"};
const srcDir = './src';
const distDir = './dist';
const input = `${srcDir}/iframemanager.js`;
const productionMode = !process.env.ROLLUP_WATCH;
const terserPlugin = terser({
toplevel: true,
format: {
quote_style: 1,
comments: /^!/
},
mangle: {
properties: {
regex: /^_/,
keep_quoted: true
}
},
compress: {
drop_console: true,
passes: 3
},
safari10: true
});
export default defineConfig(
[
{
input: input,
output: [
{
file: pkg.main,
name: 'iframemanager'
}
],
plugins: [
eslint({
fix: true,
include: ['./src/**'],
exclude: ['./src/scss/**']
}),
productionMode && terserPlugin,
]
},
{
input: `${srcDir}/iframemanager.css`,
output: {
file: `${distDir}/iframemanager.css`,
},
plugins: postcss({
extract: true,
plugins: [
postcssCombineDuplicatedSelectors(),
productionMode && cssnanoPlugin({
preset: ["default", {
discardComments: {
removeAll: true,
}
}]
})
]
}),
onwarn(warning, warn) {
if(warning.code === 'FILE_NAME_CONFLICT') return;
warn(warning);
}
}
]
);