Skip to content

Commit 169cb65

Browse files
committed
Vite/Rollup fixups
1 parent 45a8fed commit 169cb65

File tree

8 files changed

+49
-13
lines changed

8 files changed

+49
-13
lines changed

examples/minimal/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
<div id="app" style="height: 100vh">
99
<!-- Webamp will attempt to center itself within this div -->
1010
</div>
11-
<script src="https://unpkg.com/webamp@1.4.2/built/webamp.bundle.min.js"></script>
12-
<script>
13-
const Webamp = window.Webamp;
11+
<!--<script src="../../packages/webamp/built/webamp.bundle.min.js"></script>-->
12+
<script type="module">
13+
import Webamp from "../../packages/webamp/built/webamp.bundle.mjs";
1414
const webamp = new Webamp({
1515
initialTracks: [
1616
{

examples/minimalMilkdrop/index.html

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<div id="app" style="height: 100vh">
99
<!-- Webamp will attempt to center itself within this div -->
1010
</div>
11-
<script src="https://unpkg.com/webamp@1.5.0/built/webamp.bundle.min.js"></script>
11+
<script src="../../packages/webamp/built/webamp.bundle.min.js"></script>
1212
<script src="https://unpkg.com/butterchurn@2.6.7/lib/butterchurn.min.js"></script>
1313
<script src="https://unpkg.com/butterchurn-presets@2.4.7/lib/butterchurnPresets.min.js"></script>
1414
<script>
@@ -40,11 +40,17 @@
4040
},
4141
butterchurnOpen: true,
4242
},
43-
__initialWindowLayout: {
44-
main: { position: { x: 0, y: 0 } },
45-
equalizer: { position: { x: 0, y: 116 } },
46-
playlist: { position: { x: 0, y: 232 }, size: [0, 4] },
47-
milkdrop: { position: { x: 275, y: 0 }, size: [7, 12] },
43+
windowLayout: {
44+
main: { position: { top: 0, left: 0 } },
45+
equalizer: { position: { top: 116, left: 0 } },
46+
playlist: {
47+
position: { top: 232, left: 0 },
48+
size: { extraWidth: 0, extraHeight: 4 },
49+
},
50+
milkdrop: {
51+
position: { top: 0, left: 275 },
52+
size: { extraHeight: 12, extraWidth: 7 },
53+
},
4854
},
4955
});
5056
webamp.renderWhenReady(document.getElementById("app"));

packages/webamp/.eslintignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
*.min.js
22
built/
3-
dist/
43
coverage/
54
**/node_modules/
65
examples/webpack/bundle.js

packages/webamp/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
**/node_modules
22

3-
/dist
43
/built
54
/demo/built
65
/coverage

packages/webamp/demo/js/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import React from "react";
12
import * as Sentry from "@sentry/browser";
23
import ReactDOM from "react-dom/client";
34
// @ts-ignore
@@ -87,6 +88,7 @@ async function main() {
8788
}
8889
let soundcloudPlaylist = null;
8990
if (soundcloudPlaylistId != null) {
91+
// @ts-ignore
9092
soundcloudPlaylist = await SoundCloud.getPlaylist(soundcloudPlaylistId);
9193
}
9294
const config = await getWebampConfig(screenshot, skinUrl, soundcloudPlaylist);

packages/webamp/scripts/rollupPlugins.mjs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import postcssOptimizeDataUriPngs from "./postcss-optimize-data-uri-pngs.js";
1010
import atImport from "postcss-import";
1111
import { babel } from "@rollup/plugin-babel";
1212
import nodePolyfills from "rollup-plugin-polyfill-node";
13+
import path from "node:path";
1314

1415
/**
1516
* @return {import('rollup').InputOptions}
@@ -21,6 +22,7 @@ export function getPlugins({ minify, outputFile, vite }) {
2122
values: { "process.env.NODE_ENV": JSON.stringify("production") },
2223
preventAssignment: true,
2324
}),
25+
vite ? null : stripInlineSuffix(),
2426
// https://rollupjs.org/troubleshooting/#warning-treating-module-as-external-dependency
2527
// TODO: We could offer a version which does not inline React/React-DOM
2628
nodeResolve(),
@@ -57,3 +59,27 @@ export function getPlugins({ minify, outputFile, vite }) {
5759

5860
return plugins;
5961
}
62+
63+
// Vite expects `?inline` for CSS imports that we don't want to be auto
64+
// injected. This hack strips that suffix here in Rollup for the library build.
65+
function stripInlineSuffix() {
66+
return {
67+
name: "strip-inline-suffix",
68+
resolveId(source, importer) {
69+
if (source.includes("?inline")) {
70+
// Remove the `?inline` part from the import path
71+
const cleanedSource = source.replace("?inline", "");
72+
73+
// Resolve the cleaned source to an absolute path
74+
const resolvedPath = path.resolve(
75+
path.dirname(importer),
76+
cleanedSource
77+
);
78+
79+
return resolvedPath; // Return the absolute path
80+
}
81+
82+
return null; // Return null to let other plugins handle the path if not modified
83+
},
84+
};
85+
}

packages/webamp/vite.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export default defineConfig({
1111
optimizeDeps: {
1212
include: ["winamp-eqf"],
1313
},
14-
rollup: {},
1514
plugins: [
1615
...getPlugins({ minify: true, outputFile: "foo", vite: true }),
1716
/*

yarn.lock

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15069,11 +15069,16 @@ graphql-ws@5.12.1:
1506915069
resolved "https://registry.yarnpkg.com/graphql-ws/-/graphql-ws-5.12.1.tgz#c62d5ac54dbd409cc6520b0b39de374b3d59d0dd"
1507015070
integrity sha512-umt4f5NnMK46ChM2coO36PTFhHouBrK9stWWBczERguwYrGnPNxJ9dimU6IyOBfOkC6Izhkg4H8+F51W/8CYDg==
1507115071

15072-
graphql@16.8.1, graphql@^16.8.1, graphql@^16.9.0:
15072+
graphql@^16.8.1:
1507315073
version "16.8.1"
1507415074
resolved "https://registry.yarnpkg.com/graphql/-/graphql-16.8.1.tgz#1930a965bef1170603702acdb68aedd3f3cf6f07"
1507515075
integrity sha512-59LZHPdGZVh695Ud9lRzPBVTtlX9ZCV150Er2W43ro37wVof0ctenSaskPPjN7lVTIN8mSZt8PHUNKZuNQUuxw==
1507615076

15077+
graphql@^16.9.0:
15078+
version "16.9.0"
15079+
resolved "https://registry.yarnpkg.com/graphql/-/graphql-16.9.0.tgz#1c310e63f16a49ce1fbb230bd0a000e99f6f115f"
15080+
integrity sha512-GGTKBX4SD7Wdb8mqeDLni2oaRGYQWjWHGKPQ24ZMnUtKfcsVoiv4uX8+LJr1K6U5VW2Lu1BwJnj7uiori0YtRw==
15081+
1507715082
grats@^0.0.28:
1507815083
version "0.0.28"
1507915084
resolved "https://registry.yarnpkg.com/grats/-/grats-0.0.28.tgz#232fa29cc4387607950e2e408e18c26582586e1b"

0 commit comments

Comments
 (0)