Import assets from the assets/ directory

> Will be easier towards the future when adding more assets. Probably best to keep style.css for now for backwards compat though.
>
> *-- https://github.com/vector-im/hydrogen-web/pull/693#discussion_r853844282*
This commit is contained in:
Eric Eastwood 2022-05-31 15:30:56 -05:00
parent 8b2299852e
commit 38c3774869
5 changed files with 6 additions and 8 deletions

View File

@ -48,8 +48,8 @@ const assetPaths = {
wasmBundle: olmJsPath wasmBundle: olmJsPath
} }
}; };
import "hydrogen-view-sdk/theme-element-light.css"; import "hydrogen-view-sdk/assets/theme-element-light.css";
// OR import "hydrogen-view-sdk/theme-element-dark.css"; // OR import "hydrogen-view-sdk/assets/theme-element-dark.css";
async function main() { async function main() {
const app = document.querySelector<HTMLDivElement>('#app')! const app = document.querySelector<HTMLDivElement>('#app')!

View File

@ -10,8 +10,6 @@
}, },
"./paths/vite": "./paths/vite.js", "./paths/vite": "./paths/vite.js",
"./style.css": "./asset-build/assets/theme-element-light.css", "./style.css": "./asset-build/assets/theme-element-light.css",
"./theme-element-light.css": "./asset-build/assets/theme-element-light.css",
"./theme-element-dark.css": "./asset-build/assets/theme-element-dark.css",
"./main.js": "./asset-build/assets/main.js", "./main.js": "./asset-build/assets/main.js",
"./download-sandbox.html": "./asset-build/assets/download-sandbox.html", "./download-sandbox.html": "./asset-build/assets/download-sandbox.html",
"./assets/*": "./asset-build/assets/*" "./assets/*": "./asset-build/assets/*"

View File

@ -13,7 +13,7 @@ const assetPaths = {
wasmBundle: olmJsPath wasmBundle: olmJsPath
} }
}; };
import "hydrogen-view-sdk/theme-element-light.css"; import "hydrogen-view-sdk/assets/theme-element-light.css";
console.log('hydrogenViewSdk', hydrogenViewSdk); console.log('hydrogenViewSdk', hydrogenViewSdk);
console.log('assetPaths', assetPaths); console.log('assetPaths', assetPaths);

View File

@ -6,7 +6,7 @@ const hydrogenViewSdk = require('hydrogen-view-sdk');
// Worker // Worker
require.resolve('hydrogen-view-sdk/main.js'); require.resolve('hydrogen-view-sdk/main.js');
// Styles // Styles
require.resolve('hydrogen-view-sdk/theme-element-light.css'); require.resolve('hydrogen-view-sdk/assets/theme-element-light.css');
// Can access files in the assets/* directory // Can access files in the assets/* directory
require.resolve('hydrogen-view-sdk/assets/main.js'); require.resolve('hydrogen-view-sdk/assets/main.js');

View File

@ -4,7 +4,7 @@ const themeBuilder = require("./scripts/build-plugins/rollup-plugin-build-themes
const {commonOptions, compiledVariables} = require("./vite.common-config.js"); const {commonOptions, compiledVariables} = require("./vite.common-config.js");
// These paths will be saved without their hash so they have a consisent path to // These paths will be saved without their hash so they have a consisent path to
// reference // reference in imports.
const pathsToExport = [ const pathsToExport = [
"main.js", "main.js",
"download-sandbox.html", "download-sandbox.html",