decky-plugin-template/rollup.config.js

50 lines
1.5 KiB
JavaScript
Raw Normal View History

2022-04-23 00:42:11 +02:00
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
2022-04-23 00:42:11 +02:00
import { nodeResolve } from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
import typescript from '@rollup/plugin-typescript';
import { defineConfig } from 'rollup';
2024-06-13 18:11:44 -04:00
import del from 'rollup-plugin-delete';
2022-05-25 21:34:31 +02:00
import importAssets from 'rollup-plugin-import-assets';
2024-06-13 18:11:44 -04:00
import externalGlobals from 'rollup-plugin-external-globals';
2022-05-25 21:34:31 +02:00
2024-06-13 18:11:44 -04:00
// replace "assert" with "with" once node implements that
import manifest from './plugin.json' assert { type: 'json' };
2022-04-23 00:42:11 +02:00
export default defineConfig({
input: './src/index.tsx',
plugins: [
2024-06-13 18:11:44 -04:00
del({ targets: './dist/*', force: true }),
2022-04-23 00:42:11 +02:00
commonjs(),
2024-06-13 18:11:44 -04:00
nodeResolve({
browser: true
}),
externalGlobals({
react: 'SP_REACT',
'react-dom': 'SP_REACTDOM',
'@decky/ui': 'DFL',
'@decky/manifest': JSON.stringify(manifest)
}),
2022-04-23 00:42:11 +02:00
typescript(),
json(),
2022-04-23 00:42:11 +02:00
replace({
preventAssignment: false,
'process.env.NODE_ENV': JSON.stringify('production'),
}),
2022-05-25 21:34:31 +02:00
importAssets({
2024-06-13 18:11:44 -04:00
publicPath: `http://127.0.0.1:1337/plugins/${manifest.name}/`
2022-05-25 21:34:31 +02:00
})
2022-04-23 00:42:11 +02:00
],
context: 'window',
2024-06-13 18:11:44 -04:00
external: ['react', 'react-dom', '@decky/ui'],
2022-04-23 00:42:11 +02:00
output: {
2024-06-13 18:11:44 -04:00
dir: 'dist',
format: 'esm',
sourcemap: true,
// **Don't** change this.
sourcemapPathTransform: (relativeSourcePath) => relativeSourcePath.replace(/^\.\.\//, `decky://decky/plugin/${encodeURIComponent(manifest.name)}/`),
exports: 'default'
2022-04-23 00:42:11 +02:00
},
});
2024-06-13 18:11:44 -04:00