forked from Sian-Lee-SA/Home-Assistant-Switch-Manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
78 lines (76 loc) · 2.52 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import nodeResolve from "@rollup/plugin-node-resolve";
import json from "@rollup/plugin-json";
import babel from "@rollup/plugin-babel";
import cleanup from "rollup-plugin-cleanup";
const commonjs = require("@rollup/plugin-commonjs");
const babelTypescript = require("@babel/preset-typescript");
const babelDecorators = require("@babel/plugin-proposal-decorators");
const babelClassProperties = require("@babel/plugin-proposal-class-properties");
const ignore = require("./rollup-plugins/ignore-plugin");
const path = require("path");
const replace = require("@rollup/plugin-replace");
const { string } = require("rollup-plugin-string");
const extensions = [".js", ".ts"];
const production = !process.env.ROLLUP_WATCH;
module.exports = [
{
input: "js/main.ts",
output: {
file: "custom_components/switch_manager/assets/switch_manager_panel.js",
format: "es",
externalLiveBindings: false,
sourcemap: (!production) ? 'inline' : false
},
preserveEntrySignatures: false,
inlineDynamicImports: true,
plugins: [
nodeResolve({
extensions,
preferBuiltins: false,
browser: true,
rootDir: path.resolve(__dirname)
}),
commonjs(),
json(),
production && cleanup({
comments: 'none',
sourcemap: false,
extensions: ['js', 'ts']
}),
babel({
babelrc: false,
compact: true,
presets: [babelTypescript.default],
babelHelpers: "bundled",
plugins: [
"@babel/syntax-dynamic-import",
"@babel/plugin-proposal-optional-chaining",
"@babel/plugin-proposal-nullish-coalescing-operator",
[babelDecorators.default, { decoratorsBeforeExport: true }],
[babelClassProperties.default, { loose: true }],
].filter(Boolean),
extensions,
exclude: [require.resolve("@mdi/js/mdi.js")],
}),
string({
// Import certain extensions as strings
include: [path.join(path.resolve(__dirname), "node_modules/**/*.css")],
}),
replace({
__DEV__: false,
__BUILD__: JSON.stringify("latest"),
__VERSION__: JSON.stringify('0.0.1'),
__DEMO__: false,
__SUPERVISOR__: false,
__BACKWARDS_COMPAT__: false,
__STATIC_PATH__: "/static/",
preventAssignment: false
}),
ignore({
files: [
require.resolve("@polymer/font-roboto/roboto.js")
],
})
],
},
];