forked from Gh61/lovelace-hue-like-light-card
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.mjs
61 lines (54 loc) · 1.81 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
import typescript from 'rollup-plugin-typescript2';
import terser from '@rollup/plugin-terser';
import json from '@rollup/plugin-json';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import serve from 'rollup-plugin-serve';
const LCERROR = '\x1b[31m%s\x1b[0m'; //red
var dev = true;
const serverOptions = {
contentBase: ['./dist'],
host: '127.0.0.1',
port: 5500,
allowCrossOrigin: true,
headers: {
'Access-Control-Allow-Origin': '*',
},
};
export default cli => {
var runServer = cli.runServer || false;
return {
onwarn: function(warning) {
// Skip certain warnings
// formatjs is checking 'this' and it throws this warning
if (warning.code === 'THIS_IS_UNDEFINED' &&
(
warning.id.endsWith('node_modules\\@formatjs\\intl-utils\\lib\\src\\resolve-locale.js') ||
warning.id.endsWith('node_modules\\@formatjs\\intl-utils\\lib\\src\\diff.js')
)
) {
//console.log(warning);
return;
}
// console.warn everything else
if (warning.loc) {
console.warn(LCERROR, `${warning.loc.file} (${warning.loc.line}:${warning.loc.column})\r\n${warning.message}`);
if (warning.frame)
console.warn(warning.frame);
} else {
console.warn(LCERROR, warning.message);
}
},
input: ["src/hue-like-light-card.ts"],
output: {
dir: dev ? "./dist" : "./release",
format: "es",
},
plugins: [
json({compact:true}),
typescript(),
nodeResolve(),
runServer && serve(serverOptions),
!dev && terser()
]
}
}