66 lines
1.8 KiB
JavaScript
66 lines
1.8 KiB
JavaScript
import commonjs from "@rollup/plugin-commonjs";
|
|
import nodeResolve from "@rollup/plugin-node-resolve";
|
|
import terser from "@rollup/plugin-terser";
|
|
import copy from "rollup-plugin-copy";
|
|
import typescript from "@rollup/plugin-typescript";
|
|
import path from "node:path";
|
|
import url from "node:url";
|
|
|
|
const isWatching = !!process.env.ROLLUP_WATCH;
|
|
const sdPlugin = "com.ryan-kegel.dynamic-deck.sdPlugin";
|
|
|
|
/**
|
|
* @type {import('rollup').RollupOptions}
|
|
*/
|
|
const config = {
|
|
input: "src/plugin.ts",
|
|
output: {
|
|
file: `${sdPlugin}/bin/plugin.js`,
|
|
sourcemap: isWatching,
|
|
sourcemapPathTransform: (relativeSourcePath, sourcemapPath) => {
|
|
return url.pathToFileURL(
|
|
path.resolve(path.dirname(sourcemapPath), relativeSourcePath),
|
|
).href;
|
|
},
|
|
},
|
|
plugins: [
|
|
copy({
|
|
targets: [
|
|
{ src: "src/ui", dest: "com.ryan-kegel.dynamic-deck.sdPlugin" },
|
|
{ src: "src/imgs", dest: "com.ryan-kegel.dynamic-deck.sdPlugin" },
|
|
{ src: "src/scripts", dest: "com.ryan-kegel.dynamic-deck.sdPlugin" },
|
|
{ src: "src/services", dest: "com.ryan-kegel.dynamic-deck.sdPlugin" },
|
|
{ src: "src/utils", dest: "com.ryan-kegel.dynamic-deck.sdPlugin" }
|
|
],
|
|
}),
|
|
{
|
|
name: "watch-externals",
|
|
buildStart: function () {
|
|
this.addWatchFile(`${sdPlugin}/manifest.json`);
|
|
},
|
|
},
|
|
typescript({
|
|
mapRoot: isWatching ? "./" : undefined,
|
|
}),
|
|
nodeResolve({
|
|
browser: false,
|
|
exportConditions: ["node"],
|
|
preferBuiltins: true,
|
|
}),
|
|
commonjs(),
|
|
!isWatching && terser(),
|
|
{
|
|
name: "emit-module-package-file",
|
|
generateBundle() {
|
|
this.emitFile({
|
|
fileName: "package.json",
|
|
source: `{ "type": "module" }`,
|
|
type: "asset",
|
|
});
|
|
},
|
|
},
|
|
],
|
|
};
|
|
|
|
export default config;
|