mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
Fix formatting
This commit is contained in:
parent
ff98ef4465
commit
0a95eb0940
@ -187,64 +187,64 @@ module.exports = function buildThemes(options) {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
transformIndexHtml(_, ctx) {
|
transformIndexHtml(_, ctx) {
|
||||||
if (isDevelopment) {
|
if (isDevelopment) {
|
||||||
// Don't add default stylesheets to index.html on dev
|
// Don't add default stylesheets to index.html on dev
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let darkThemeLocation, lightThemeLocation;
|
let darkThemeLocation, lightThemeLocation;
|
||||||
for (const [, bundle] of Object.entries(ctx.bundle)) {
|
for (const [, bundle] of Object.entries(ctx.bundle)) {
|
||||||
if (bundle.name === defaultDark) {
|
if (bundle.name === defaultDark) {
|
||||||
darkThemeLocation = bundle.fileName;
|
darkThemeLocation = bundle.fileName;
|
||||||
}
|
|
||||||
if (bundle.name === defaultLight) {
|
|
||||||
lightThemeLocation = bundle.fileName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
tag: "link",
|
|
||||||
attrs: {
|
|
||||||
rel: "stylesheet",
|
|
||||||
type: "text/css",
|
|
||||||
media: "(prefers-color-scheme: dark)",
|
|
||||||
href: `./${darkThemeLocation}`,
|
|
||||||
}
|
}
|
||||||
},
|
if (bundle.name === defaultLight) {
|
||||||
{
|
lightThemeLocation = bundle.fileName;
|
||||||
tag: "link",
|
|
||||||
attrs: {
|
|
||||||
rel: "stylesheet",
|
|
||||||
type: "text/css",
|
|
||||||
media: "(prefers-color-scheme: light)",
|
|
||||||
href: `./${lightThemeLocation}`,
|
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
];
|
return [
|
||||||
},
|
{
|
||||||
|
tag: "link",
|
||||||
|
attrs: {
|
||||||
|
rel: "stylesheet",
|
||||||
|
type: "text/css",
|
||||||
|
media: "(prefers-color-scheme: dark)",
|
||||||
|
href: `./${darkThemeLocation}`,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
tag: "link",
|
||||||
|
attrs: {
|
||||||
|
rel: "stylesheet",
|
||||||
|
type: "text/css",
|
||||||
|
media: "(prefers-color-scheme: light)",
|
||||||
|
href: `./${lightThemeLocation}`,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
];
|
||||||
|
},
|
||||||
|
|
||||||
generateBundle(_, bundle) {
|
generateBundle(_, bundle) {
|
||||||
const { assetMap, chunkMap, runtimeThemeChunk } = parseBundle(bundle);
|
const { assetMap, chunkMap, runtimeThemeChunk } = parseBundle(bundle);
|
||||||
for (const [location, chunkArray] of chunkMap) {
|
for (const [location, chunkArray] of chunkMap) {
|
||||||
const manifest = require(`${location}/manifest.json`);
|
const manifest = require(`${location}/manifest.json`);
|
||||||
const compiledVariables = options.compiledVariables.get(location);
|
const compiledVariables = options.compiledVariables.get(location);
|
||||||
const derivedVariables = compiledVariables["derived-variables"];
|
const derivedVariables = compiledVariables["derived-variables"];
|
||||||
const icon = compiledVariables["icon"];
|
const icon = compiledVariables["icon"];
|
||||||
manifest.source = {
|
manifest.source = {
|
||||||
"built-asset": chunkArray.map(chunk => assetMap.get(chunk.fileName).fileName),
|
"built-asset": chunkArray.map(chunk => assetMap.get(chunk.fileName).fileName),
|
||||||
"runtime-asset": assetMap.get(runtimeThemeChunk.fileName).fileName,
|
"runtime-asset": assetMap.get(runtimeThemeChunk.fileName).fileName,
|
||||||
"derived-variables": derivedVariables,
|
"derived-variables": derivedVariables,
|
||||||
"icon": icon
|
"icon": icon
|
||||||
};
|
};
|
||||||
const name = `theme-${manifest.name}.json`;
|
const name = `theme-${manifest.name}.json`;
|
||||||
this.emitFile({
|
this.emitFile({
|
||||||
type: "asset",
|
type: "asset",
|
||||||
name,
|
name,
|
||||||
source: JSON.stringify(manifest),
|
source: JSON.stringify(manifest),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user