Skip to content

Commit

Permalink
Import assets from the assets/ directory
Browse files Browse the repository at this point in the history
> Will be easier towards the future when adding more assets. Probably best to keep style.css for now for backwards compat though.
>
> *-- #693 (comment)
  • Loading branch information
MadLittleMods committed May 31, 2022
1 parent 8b22998 commit 38c3774
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions doc/SDK.md
Expand Up @@ -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<HTMLDivElement>('#app')!
Expand Down
2 changes: 0 additions & 2 deletions scripts/sdk/base-manifest.json
Expand Up @@ -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/*"
Expand Down
2 changes: 1 addition & 1 deletion scripts/sdk/test/esm-entry.ts
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion scripts/sdk/test/test-sdk-in-commonjs-env.js
Expand Up @@ -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');

Expand Down
4 changes: 2 additions & 2 deletions vite.sdk-assets-config.js
Expand Up @@ -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",
Expand Down

0 comments on commit 38c3774

Please sign in to comment.