mirror of
https://github.com/trafficlunar/jellyfin-spicetify.git
synced 2026-06-13 19:07:06 +00:00
feat: loading indicators, copy quick connect code
Also adds .editorconfig, formats most files, and remove archive false on workflow until nightly.link adds support for it
This commit is contained in:
parent
eee96c84af
commit
71c62c3f07
15 changed files with 2878 additions and 2817 deletions
87
build.ts
87
build.ts
|
|
@ -9,34 +9,34 @@ const isLocal = process.argv.includes("--local");
|
|||
const isWatch = process.argv.includes("--watch");
|
||||
|
||||
const options: BuildOptions = {
|
||||
entryPoints: ["src/main.ts"],
|
||||
outfile: "./dist/jellyfin-spicetify.js",
|
||||
bundle: true,
|
||||
minify: isLocal,
|
||||
platform: "browser",
|
||||
external: ["react", "react-dom"],
|
||||
plugins: [
|
||||
CssModulesPlugin({ pattern: "jellyfin-spicetify__[local]", localsConvention: "camelCaseOnly" }),
|
||||
{
|
||||
name: "external-global",
|
||||
setup(build) {
|
||||
build.onResolve({ filter: /^(react|react-dom)$/ }, (args) => ({
|
||||
path: args.path,
|
||||
namespace: "external-global",
|
||||
}));
|
||||
build.onLoad({ filter: /.*/, namespace: "external-global" }, (args) => ({
|
||||
contents: `module.exports = Spicetify.${args.path === "react" ? "React" : "ReactDOM"};`,
|
||||
}));
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "on-end",
|
||||
setup(build) {
|
||||
build.onEnd(() => {
|
||||
const js = readFileSync("./dist/jellyfin-spicetify.js", "utf-8");
|
||||
const css = readFileSync("./dist/jellyfin-spicetify.css", "utf-8");
|
||||
entryPoints: ["src/main.ts"],
|
||||
outfile: "./dist/jellyfin-spicetify.js",
|
||||
bundle: true,
|
||||
minify: isLocal,
|
||||
platform: "browser",
|
||||
external: ["react", "react-dom"],
|
||||
plugins: [
|
||||
CssModulesPlugin({ pattern: "jellyfin-spicetify__[local]", localsConvention: "camelCaseOnly" }),
|
||||
{
|
||||
name: "external-global",
|
||||
setup(build) {
|
||||
build.onResolve({ filter: /^(react|react-dom)$/ }, (args) => ({
|
||||
path: args.path,
|
||||
namespace: "external-global",
|
||||
}));
|
||||
build.onLoad({ filter: /.*/, namespace: "external-global" }, (args) => ({
|
||||
contents: `module.exports = Spicetify.${args.path === "react" ? "React" : "ReactDOM"};`,
|
||||
}));
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "on-end",
|
||||
setup(build) {
|
||||
build.onEnd(() => {
|
||||
const js = readFileSync("./dist/jellyfin-spicetify.js", "utf-8");
|
||||
const css = readFileSync("./dist/jellyfin-spicetify.css", "utf-8");
|
||||
|
||||
const wrapped = `
|
||||
const wrapped = `
|
||||
// https://github.com/trafficlunar/jellyfin-spicetify
|
||||
(async function() {
|
||||
while (!Spicetify.React || !Spicetify.ReactDOM) {
|
||||
|
|
@ -49,25 +49,28 @@ const options: BuildOptions = {
|
|||
${js}
|
||||
})();`.trim();
|
||||
|
||||
writeFileSync("./dist/jellyfin-spicetify.js", wrapped);
|
||||
writeFileSync("./dist/jellyfin-spicetify.js", wrapped);
|
||||
|
||||
if (!isLocal) {
|
||||
const path =
|
||||
os.platform() === "win32"
|
||||
? join(process.env.APPDATA!, "spicetify", "Extensions", "jellyfin-spicetify.js")
|
||||
: join(process.env.HOME!, ".config", "spicetify", "Extensions", "jellyfin-spicetify.js");
|
||||
if (!isLocal) {
|
||||
const path =
|
||||
os.platform() === "win32"
|
||||
? join(process.env.APPDATA!, "spicetify", "Extensions", "jellyfin-spicetify.js")
|
||||
: join(process.env.HOME!, ".config", "spicetify", "Extensions", "jellyfin-spicetify.js");
|
||||
|
||||
copyFileSync("./dist/jellyfin-spicetify.js", path);
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
],
|
||||
copyFileSync("./dist/jellyfin-spicetify.js", path);
|
||||
}
|
||||
|
||||
console.log("Built!");
|
||||
});
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
if (isWatch) {
|
||||
const ctx = await context(options);
|
||||
await ctx.watch();
|
||||
const ctx = await context(options);
|
||||
console.log("Watching...");
|
||||
await ctx.watch();
|
||||
} else {
|
||||
await build(options);
|
||||
await build(options);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue