This repository has been archived by the owner on Jun 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrollup.config.mjs.old
92 lines (89 loc) · 2.53 KB
/
rollup.config.mjs.old
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
import alias from '@rollup/plugin-alias';
import babel from "@rollup/plugin-babel";
import cjs from "@rollup/plugin-commonjs";
import pkg from "./package.json" assert {type: 'json'};
import replace from "@rollup/plugin-replace";
import resolve from "@rollup/plugin-node-resolve";
import serve from "rollup-plugin-serve";
import stripCode from "rollup-plugin-strip-code";
// import terser from '@rollup/plugin-terser';
import fs from 'node:fs';
import path from 'node:path';
import { buildPluginsHtml, buildPluginsCss, transformToPlugin } from './rollup-plugins.mjs';
import terser from '@rollup/plugin-terser';
const prod = !process.env.ROLLUP_WATCH;
const meta = {
name: pkg.name,
version: pkg.version,
author: pkg.author,
repository: {
type: pkg.repository.type,
url: pkg.repository.url,
},
description: pkg.description,
displayName: "Better Sounding",
hook: "contextmenu",
className: "plugin-lhpane",
classNameMobile: "window",
exclusive: "lhpane",
attachPointMobile: "#plugins",
};
export default {
input: "src/plugin.js",
output: {
file: prod ? "dist/plugin.js" : "dev/plugin.js",
name: "plugin.js",
format: "es",
},
external: moduleId => moduleId.startsWith('@windy/') || moduleId.startsWith('@plugins/'),
plugins: [
replace({
values: {
"process.env.NODE_ENV": JSON.stringify(prod ? "production" : "development"),
},
preventAssignment: true,
}),
prod && stripCode({
start_comment: 'strip-from-prod',
end_comment: 'end-strip-from-prod'
}),
buildPluginsHtml(),
buildPluginsCss(),
resolve(),
alias({
entries: {
react: path.resolve('node_modules/preact/compat/src/index.js'),
'react-dom': path.resolve('node_modules/preact/compat/src/index.js'),
}
}),
cjs({
include: "node_modules/**",
}),
!prod &&
serve({
contentBase: "dev",
port: 9999,
https: {
key: fs.readFileSync('key.pem'),
cert: fs.readFileSync('certificate.pem'),
},
headers: {
'Access-Control-Allow-Origin': '*',
},
}),
transformToPlugin(meta),
babel({
presets: [
[
"@babel/preset-env",
{
targets: "last 2 versions and not ie < 20 and > .5%",
},
],
],
plugins: [["@babel/plugin-transform-react-jsx", { pragma: "h" }]],
babelHelpers: 'bundled',
}),
prod && terser({ output: { comments: false } }),
],
};