From 38c377486916b94f1e134e919e4f9ac543dbbe06 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Tue, 31 May 2022 15:30:56 -0500 Subject: [PATCH] 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* --- doc/SDK.md | 4 ++-- scripts/sdk/base-manifest.json | 2 -- scripts/sdk/test/esm-entry.ts | 2 +- scripts/sdk/test/test-sdk-in-commonjs-env.js | 2 +- vite.sdk-assets-config.js | 4 ++-- 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/doc/SDK.md b/doc/SDK.md index 3f5bdb09..c8f5197f 100644 --- a/doc/SDK.md +++ b/doc/SDK.md @@ -48,8 +48,8 @@ const assetPaths = { wasmBundle: olmJsPath } }; -import "hydrogen-view-sdk/theme-element-light.css"; -// OR import "hydrogen-view-sdk/theme-element-dark.css"; +import "hydrogen-view-sdk/assets/theme-element-light.css"; +// OR import "hydrogen-view-sdk/assets/theme-element-dark.css"; async function main() { const app = document.querySelector('#app')! diff --git a/scripts/sdk/base-manifest.json b/scripts/sdk/base-manifest.json index de940752..441d4189 100644 --- a/scripts/sdk/base-manifest.json +++ b/scripts/sdk/base-manifest.json @@ -10,8 +10,6 @@ }, "./paths/vite": "./paths/vite.js", "./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", "./download-sandbox.html": "./asset-build/assets/download-sandbox.html", "./assets/*": "./asset-build/assets/*" diff --git a/scripts/sdk/test/esm-entry.ts b/scripts/sdk/test/esm-entry.ts index 1f3b7114..17bbd8bb 100644 --- a/scripts/sdk/test/esm-entry.ts +++ b/scripts/sdk/test/esm-entry.ts @@ -13,7 +13,7 @@ const assetPaths = { 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('assetPaths', assetPaths); diff --git a/scripts/sdk/test/test-sdk-in-commonjs-env.js b/scripts/sdk/test/test-sdk-in-commonjs-env.js index 3fd19d46..333f1573 100644 --- a/scripts/sdk/test/test-sdk-in-commonjs-env.js +++ b/scripts/sdk/test/test-sdk-in-commonjs-env.js @@ -6,7 +6,7 @@ const hydrogenViewSdk = require('hydrogen-view-sdk'); // Worker require.resolve('hydrogen-view-sdk/main.js'); // 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 require.resolve('hydrogen-view-sdk/assets/main.js'); diff --git a/vite.sdk-assets-config.js b/vite.sdk-assets-config.js index beb7bb37..7174b8db 100644 --- a/vite.sdk-assets-config.js +++ b/vite.sdk-assets-config.js @@ -3,8 +3,8 @@ const mergeOptions = require('merge-options'); const themeBuilder = require("./scripts/build-plugins/rollup-plugin-build-themes"); const {commonOptions, compiledVariables} = require("./vite.common-config.js"); -// These paths will be saved without their hash so they havea consisent path to -// reference +// These paths will be saved without their hash so they have a consisent path to +// reference in imports. const pathsToExport = [ "main.js", "download-sandbox.html",