Merge pull request #746 from vector-im/madlittlemods/assets-path-for-assets

Import SDK assets from the `assets/` directory
This commit is contained in:
Bruno Windels 2022-07-04 06:53:37 +00:00 committed by GitHub
commit fba3275f5b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 7 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

@ -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

@ -3,8 +3,9 @@ const mergeOptions = require('merge-options');
const themeBuilder = require("./scripts/build-plugins/rollup-plugin-build-themes"); 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 havea consisent path to // These paths will be saved without their hash so they have a consisent path
// reference // that we can reference in our `package.json` `exports`. And so people can import
// them with a consistent path.
const pathsToExport = [ const pathsToExport = [
"main.js", "main.js",
"download-sandbox.html", "download-sandbox.html",
@ -21,7 +22,8 @@ export default mergeOptions(commonOptions, {
output: { output: {
assetFileNames: (chunkInfo) => { assetFileNames: (chunkInfo) => {
// Get rid of the hash so we can consistently reference these // Get rid of the hash so we can consistently reference these
// files in our `package.json` `exports` // files in our `package.json` `exports`. And so people can
// import them with a consistent path.
if(pathsToExport.includes(path.basename(chunkInfo.name))) { if(pathsToExport.includes(path.basename(chunkInfo.name))) {
return "assets/[name].[ext]"; return "assets/[name].[ext]";
} }