Skip to content

Commit

Permalink
Removed need for build input file
Browse files Browse the repository at this point in the history
  • Loading branch information
Joppe Kroon committed May 30, 2024
1 parent 8ffcd7f commit 00008d2
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
2 changes: 0 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ rimrafSync('docs');

export default [
{ /* Generate recoloring css */
input: 'src/scripts/app.js',
output: {
dir: 'themes/'
},
Expand All @@ -29,7 +28,6 @@ export default [
]
},
{ /* Legacy location for styles */
input: 'src/scripts/app.js',
output: {
dir: 'public/'
},
Expand Down
1 change: 0 additions & 1 deletion src/scripts/app.js

This file was deleted.

32 changes: 31 additions & 1 deletion src/scripts/create-userstyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,39 @@ import { readFileSync } from 'fs';
import { themes, legacyTheme as theme } from "../themes/index.js";

export default function createUserstyles(version, stylesDir) {
// No need for build input file thanks to https://stackoverflow.com/a/72053820/127947
const emptyRunId = 'no-need-for-input';

return {
name: 'create-userstyle-plugin',
generateBundle(_options, _bundle) {
buildStart() {
// To stop rollup whining about an input file
this.emitFile({
id: emptyRunId,
fileName: emptyRunId,
type: 'chunk',
});
},
resolveId(source) {
if (source === emptyRunId) {
// The leading \0 instructs other plugins and rollup not to try to resolve, load or transform this module
return `\0${emptyRunId}`;
}
return null;
},
load(id) {
if (id.includes(emptyRunId)) {
// some random code to avoid rollup empty chunk warning
return 'export const empty = true;';
}

return null;
},
generateBundle(_options, bundle) {
if (bundle[emptyRunId]) {
delete bundle[emptyRunId];
}

const styles = userStyles(stylesDir);

this.emitFile({
Expand Down

0 comments on commit 00008d2

Please sign in to comment.