mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
Move web-specific files to platform/web
This commit is contained in:
parent
b6d0d54241
commit
e8dff6d16b
@ -72,7 +72,7 @@ async function build({modernOnly, overrideImports, overrideCss}) {
|
|||||||
if (overrideImports) {
|
if (overrideImports) {
|
||||||
importOverridesMap = await readImportOverrides(overrideImports);
|
importOverridesMap = await readImportOverrides(overrideImports);
|
||||||
}
|
}
|
||||||
const devHtml = await fs.readFile(path.join(projectDir, "public/index.html"), "utf8");
|
const devHtml = await fs.readFile(path.join(snowpackOutPath, "index.html"), "utf8");
|
||||||
const doc = cheerio.load(devHtml);
|
const doc = cheerio.load(devHtml);
|
||||||
const themes = [];
|
const themes = [];
|
||||||
findThemes(doc, themeName => {
|
findThemes(doc, themeName => {
|
||||||
@ -105,9 +105,9 @@ async function build({modernOnly, overrideImports, overrideCss}) {
|
|||||||
await buildCssBundles(buildCssLegacy, themes, assets, overrideCss);
|
await buildCssBundles(buildCssLegacy, themes, assets, overrideCss);
|
||||||
await buildManifest(assets);
|
await buildManifest(assets);
|
||||||
// all assets have been added, create a hash from all assets name to cache unhashed files like index.html
|
// all assets have been added, create a hash from all assets name to cache unhashed files like index.html
|
||||||
assets.addToHashForAll("public/index.html", devHtml);
|
assets.addToHashForAll("index.html", devHtml);
|
||||||
let swSource = await fs.readFile(path.join(projectDir, srcPath("platform/web/service-worker.js")), "utf8");
|
let swSource = await fs.readFile(path.join(snowpackOutPath, "service-worker.js"), "utf8");
|
||||||
assets.addToHashForAll("sw.js", swSource);
|
assets.addToHashForAll("service-worker.js", swSource);
|
||||||
|
|
||||||
const globalHash = assets.hashForAll();
|
const globalHash = assets.hashForAll();
|
||||||
|
|
||||||
@ -166,7 +166,7 @@ async function buildHtml(doc, version, baseConfig, globalHash, modernOnly, asset
|
|||||||
const configJSON = JSON.stringify(Object.assign({}, baseConfig, {
|
const configJSON = JSON.stringify(Object.assign({}, baseConfig, {
|
||||||
worker: assets.has("worker.js") ? assets.resolve(`worker.js`) : null,
|
worker: assets.has("worker.js") ? assets.resolve(`worker.js`) : null,
|
||||||
downloadSandbox: assets.resolve("download-sandbox.html"),
|
downloadSandbox: assets.resolve("download-sandbox.html"),
|
||||||
serviceWorker: "sw.js",
|
serviceWorker: "service-worker.js",
|
||||||
olm: {
|
olm: {
|
||||||
wasm: assets.resolve("olm.wasm"),
|
wasm: assets.resolve("olm.wasm"),
|
||||||
legacyBundle: assets.resolve("olm_legacy.js"),
|
legacyBundle: assets.resolve("olm_legacy.js"),
|
||||||
@ -334,7 +334,7 @@ async function buildServiceWorker(swSource, version, globalHash, assets) {
|
|||||||
swSource = replaceStringInSource("NOTIFICATION_BADGE_ICON", assets.resolve("icon.png"));
|
swSource = replaceStringInSource("NOTIFICATION_BADGE_ICON", assets.resolve("icon.png"));
|
||||||
|
|
||||||
// service worker should not have a hashed name as it is polled by the browser for updates
|
// service worker should not have a hashed name as it is polled by the browser for updates
|
||||||
await assets.writeUnhashed("sw.js", swSource);
|
await assets.writeUnhashed("service-worker.js", swSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function buildCssBundles(buildFn, themes, assets, mainCssFile = null) {
|
async function buildCssBundles(buildFn, themes, assets, mainCssFile = null) {
|
||||||
|
@ -4,10 +4,10 @@
|
|||||||
/** @type {import("snowpack").SnowpackUserConfig } */
|
/** @type {import("snowpack").SnowpackUserConfig } */
|
||||||
module.exports = {
|
module.exports = {
|
||||||
mount: {
|
mount: {
|
||||||
|
// More specific paths before less specific paths (if they overlap)
|
||||||
|
"src/platform/web/docroot": "/",
|
||||||
"src": "/src",
|
"src": "/src",
|
||||||
"public": "/",
|
|
||||||
"lib": {url: "/lib", static: true },
|
"lib": {url: "/lib", static: true },
|
||||||
"src/platform/web/ui/css/themes": "/themes",
|
|
||||||
"assets": "/assets",
|
"assets": "/assets",
|
||||||
/* ... */
|
/* ... */
|
||||||
},
|
},
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
downloadSandbox: "assets/download-sandbox.html",
|
downloadSandbox: "assets/download-sandbox.html",
|
||||||
defaultHomeServer: "matrix.org",
|
defaultHomeServer: "matrix.org",
|
||||||
// NOTE: uncomment this if you want the service worker for local development
|
// NOTE: uncomment this if you want the service worker for local development
|
||||||
// serviceWorker: "sw.js",
|
// serviceWorker: "service-worker.js",
|
||||||
// NOTE: provide push config if you want push notifs for local development
|
// NOTE: provide push config if you want push notifs for local development
|
||||||
// see assets/config.json for what the config looks like
|
// see assets/config.json for what the config looks like
|
||||||
// push: {...},
|
// push: {...},
|
Loading…
Reference in New Issue
Block a user