mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-11-20 03:25:52 +01:00
build theme css bundles
This commit is contained in:
parent
c3dc01283d
commit
fc8d2efaf2
@ -84,11 +84,10 @@ async function build() {
|
|||||||
await buildHtml(doc, version, bundleName);
|
await buildHtml(doc, version, bundleName);
|
||||||
if (legacy) {
|
if (legacy) {
|
||||||
await buildJsLegacy(bundleName);
|
await buildJsLegacy(bundleName);
|
||||||
await buildCssLegacy();
|
|
||||||
} else {
|
} else {
|
||||||
await buildJs(bundleName);
|
await buildJs(bundleName);
|
||||||
await buildCss();
|
|
||||||
}
|
}
|
||||||
|
await buildCssBundles(legacy ? buildCssLegacy : buildCss, themes);
|
||||||
if (offline) {
|
if (offline) {
|
||||||
await buildOffline(version, bundleName);
|
await buildOffline(version, bundleName);
|
||||||
}
|
}
|
||||||
@ -231,22 +230,29 @@ async function buildOffline(version, bundleName) {
|
|||||||
await fs.writeFile(path.join(targetDir, "icon-192.png"), icon);
|
await fs.writeFile(path.join(targetDir, "icon-192.png"), icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function buildCss() {
|
async function buildCssBundles(buildFn, themes) {
|
||||||
// create css bundle
|
const cssMainFile = path.join(cssDir, "main.css");
|
||||||
const cssMainFile = path.join(projectDir, "src/ui/web/css/main.css");
|
await buildFn(cssMainFile, path.join(targetDir, `${PROJECT_ID}.css`));
|
||||||
const preCss = await fs.readFile(cssMainFile, "utf8");
|
for (const theme of themes) {
|
||||||
const cssBundler = postcss([postcssImport]);
|
await buildFn(
|
||||||
const result = await cssBundler.process(preCss, {from: cssMainFile});
|
path.join(cssDir, `themes/${theme}/theme.css`),
|
||||||
await fs.writeFile(path.join(targetDir, `${PROJECT_ID}.css`), result.css, "utf8");
|
path.join(targetDir, `themes/${theme}/bundle.css`)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function buildCssLegacy() {
|
async function buildCss(entryPath, bundlePath) {
|
||||||
// create css bundle
|
const preCss = await fs.readFile(entryPath, "utf8");
|
||||||
const cssMainFile = path.join(projectDir, "src/ui/web/css/main.css");
|
const cssBundler = postcss([postcssImport]);
|
||||||
const preCss = await fs.readFile(cssMainFile, "utf8");
|
const result = await cssBundler.process(preCss, {from: entryPath});
|
||||||
|
await fs.writeFile(bundlePath, result.css, "utf8");
|
||||||
|
}
|
||||||
|
|
||||||
|
async function buildCssLegacy(entryPath, bundlePath) {
|
||||||
|
const preCss = await fs.readFile(entryPath, "utf8");
|
||||||
const cssBundler = postcss([postcssImport, cssvariables(), flexbugsFixes()]);
|
const cssBundler = postcss([postcssImport, cssvariables(), flexbugsFixes()]);
|
||||||
const result = await cssBundler.process(preCss, {from: cssMainFile});
|
const result = await cssBundler.process(preCss, {from: entryPath});
|
||||||
await fs.writeFile(path.join(targetDir, `${PROJECT_ID}.css`), result.css, "utf8");
|
await fs.writeFile(bundlePath, result.css, "utf8");
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeOrEnableScript(scriptNode, enable) {
|
function removeOrEnableScript(scriptNode, enable) {
|
||||||
|
Loading…
Reference in New Issue
Block a user