generated from SteamDeckHomebrew/decky-plugin-template
-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
rollup.config.js
54 lines (49 loc) · 1.61 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
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 {version} from "./package.json";
import {createPathTransform} from "rollup-sourcemap-path-transform";
const production = process.env["RELEASE_TYPE"] !== 'development'
export default defineConfig({
input: './src/ts/index.tsx',
plugins: [
commonjs(),
nodeResolve({browser: true}),
typescript({ sourceMap: !production, inlineSources: !production }),
json(),
replace({
preventAssignment: false,
'process.env.NODE_ENV': JSON.stringify(process.env["RELEASE_TYPE"]),
'process.env.VERSION': JSON.stringify(version),
}),
importAssets({
publicPath: `http://127.0.0.1:1337/plugins/${name}/`
})
],
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/`,
"../node_modules/.pnpm/": `/plugins/${name}/node_modules/`
},
requirePrefix: true
}) : 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',
},
});