vector-im-hydrogen-web/vite.sdk-assets-config.js

46 lines
1.5 KiB
JavaScript
Raw Normal View History

const path = require("path");
const mergeOptions = require('merge-options');
2022-04-13 13:42:38 +02:00
const themeBuilder = require("./scripts/build-plugins/rollup-plugin-build-themes");
const {commonOptions, compiledVariables} = require("./vite.common-config.js");
2022-05-31 22:35:48 +02:00
// These paths will be saved without their hash so they have a consisent path
// that we can reference in our `package.json` `exports`. And so people can import
// them with a consistent path.
const pathsToExport = [
2022-02-26 10:08:16 +01:00
"main.js",
"download-sandbox.html",
"theme-element-light.css",
"theme-element-dark.css",
];
export default mergeOptions(commonOptions, {
root: "src/",
base: "./",
build: {
outDir: "../target/asset-build/",
rollupOptions: {
output: {
assetFileNames: (chunkInfo) => {
// Get rid of the hash so we can consistently reference these
2022-05-31 22:35:48 +02:00
// files in our `package.json` `exports`. And so people can
// import them with a consistent path.
if(pathsToExport.includes(path.basename(chunkInfo.name))) {
return "assets/[name].[ext]";
}
return "assets/[name]-[hash][extname]";
}
}
}
},
2022-04-13 13:42:38 +02:00
plugins: [
themeBuilder({
themeConfig: {
2022-07-29 20:15:58 +02:00
themes: ["./src/platform/web/ui/css/themes/element"],
2022-04-13 13:42:38 +02:00
default: "element",
},
compiledVariables,
}),
],
});