generated from EmuDeck/decky-plugin-template
-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrollup.config.js
135 lines (133 loc) · 5.18 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
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
125
126
127
128
129
130
131
132
133
134
135
import {defineConfig} from "rollup";
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import styles from "rollup-plugin-styles";
import { nodeResolve } from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
import typescript from '@rollup/plugin-typescript';
import del from 'rollup-plugin-delete';
import importAssets from 'rollup-plugin-import-assets';
import externalGlobals from 'rollup-plugin-external-globals';
import svgr from '@svgr/rollup'
import manifest from "./plugin.json" assert { type: 'json' }
import pkg from "./package.json" assert { type: 'json' }
export default defineConfig({
input: './src/ts/index.tsx',
plugins: [
del({ targets: './dist/*', force: true }),
typescript(),
json(),
styles(),
svgr({icon: true}),
commonjs(),
nodeResolve({
browser: true
}),
externalGlobals({
react: 'SP_REACT',
'react-dom': 'SP_REACTDOM',
'@decky/ui': 'DFL',
'@decky/manifest': JSON.stringify(manifest),
'@decky/pkg': JSON.stringify(pkg),
}),
replace({
preventAssignment: false,
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || "production"),
}),
importAssets({
publicPath: `http://127.0.0.1:1337/plugins/${manifest.name}/`
})
],
context: 'window',
external: ['react', 'react-dom', '@decky/ui'],
treeshake: {
// Assume all external modules have imports with side effects (the default) while allowing decky libraries to treeshake
pureExternalImports: {
pure: ['@decky/ui', '@decky/api']
},
preset: 'smallest'
},
output: {
dir: 'dist',
format: 'esm',
sourcemap: true,
sourcemapPathTransform: (relativeSourcePath) => relativeSourcePath.replace(/^\.\.\//, `decky://decky/plugin/${encodeURIComponent(manifest.name)}/`),
exports: 'default'
},
})
// import commonjs from '@rollup/plugin-commonjs';
// import json from '@rollup/plugin-json';
// import {nodeResolve} from '@rollup/plugin-node-resolve';
// import replace from '@rollup/plugin-replace';
// import typescript from '@rollup/plugin-typescript';
// import {defineConfig} from 'rollup';
// import importAssets from 'rollup-plugin-import-assets';
//
// import {name} from "./plugin.json";
// import {createPathTransform} from "rollup-sourcemap-path-transform";
// import sourcemaps from "rollup-plugin-sourcemaps";
//
// const production = process.env["RELEASE_TYPE"] !== 'development'
//
// export default defineConfig({
// input: './src/ts/index.tsx',
// plugins: [
// commonjs(),
// nodeResolve({browser: true, moduleDirectories: ["node_modules"]}),
// typescript({sourceMap: !production, inlineSources: !production}),
// json(),
// replace({
// preventAssignment: false,
// 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
// 'process.env.RELEASE_TYPE': JSON.stringify(process.env.RELEASE_TYPE),
// }),
// importAssets({
// publicPath: `http://127.0.0.1:1337/plugins/${name}/`
// }),
// sourcemaps({
// // include: [
// // "**frontendMain**",
// // "**commonMain**"
// // // /\.\.\/\.\.\/\.\.\/\.\.\/\.\.\/\.\.\/\.\.\/yasdpl-kt\/src\/frontendMain\/kotlin\//,
// // // /\.\.\/\.\.\/\.\.\/\.\.\/\.\.\/\.\.\/\.\.\/yasdpl-kt\/src\/commonMain\/kotlin\//,
// // // /\.\.\/\.\.\/\.\.\/\.\.\/\.\.\/src\/frontendMain\/kotlin\//,
// // // /\.\.\/\.\.\/\.\.\/\.\.\/\.\.\/src\/commonMain\/kotlin\//
// // ]
// })
// ],
// context: 'window',
// external: ['react', 'react-dom', 'decky-frontend-lib'],
// output: {
// file: 'dist/index.js',
// sourcemap: !production ? 'inline' : false,
// sourcemapPathTransform: !production ? createPathTransform({
// prefixes: {
// "../src/src/ts/": `/plugins/${name}/src/ts/`,
// "../lib/frontend/": `/plugins/${name}/lib/frontend/`,
// // "../../compileSync/frontend/main/productionLibrary/kotlin/": `/plugins/${name}/lib/stdlib/`,
// // "../../opt/teamcity-agent/work/88b0986a7186d029/atomicfu/": `/plugins/${name}/lib/atomicfu/`,
// // "../../mnt/agent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/": `/plugins/${name}/lib/kotlinx-coroutines-core/`,
// // "../../mnt/agent/work/8d547b974a7be21f/ktor-io/": `/plugins/${name}/lib/ktor-io/`,
// "../../../../../src/frontendMain/kotlin": `/plugins/${name}/src/frontendMain/kotlin/`,
// "../../../../../src/commonMain/kotlin": `/plugins/${name}/src/commonMain/kotlin/`,
// "../../../../../../../yasdpl-kt/src/frontendMain/kotlin/": `/plugins/${name}/lib/yasdpl/src/frontendMain/kotlin/`,
// "../../../../../../../yasdpl-kt/src/commonMain/kotlin/": `/plugins/${name}/lib/yasdpl/src/commonMain/kotlin/`,
// "../node_modules/.pnpm/": `/plugins/${name}/node_modules/`
// },
// requirePrefix: false
// }) : undefined,
// footer: () => !production ? `\n//# sourceURL=http://localhost:1337/plugins/${name}/frontend_bundle` : "",
// globals: {
// react: 'SP_REACT',
// 'react-dom': 'SP_REACTDOM',
// 'decky-frontend-lib': 'DFL'
// },
// format: 'iife',
// exports: 'default',
// // dir: 'dist',
// // format: 'esm',
// // sourcemap: production,
// // sourcemapPathTransform: (relativeSourcePath) => relativeSourcePath.replace(/^\.\.\//, `decky://decky/plugin/${encodeURIComponent(name)}/`),
// // exports: 'default'
// },
// });