forked from clover-network/hydrogen-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.sdk-assets-config.js
45 lines (42 loc) · 1.47 KB
/
vite.sdk-assets-config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const path = require("path");
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 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 = [
"main.js",
"download-sandbox.html",
"theme-element-light.css",
"theme-element-dark.css",
];
export default mergeOptions(commonOptions, {
root: "src/",
base: "/css/",
build: {
outDir: "../target/asset-build/",
rollupOptions: {
output: {
assetFileNames: (chunkInfo) => {
// Get rid of the hash so we can consistently reference these
// 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]";
}
}
}
},
plugins: [
themeBuilder({
themeConfig: {
themes: ["./src/platform/web/ui/css/themes/element"],
default: "element",
},
compiledVariables,
}),
],
});