Skip to content

Commit f32bd6f

Browse files
committed
feat(): Export iife theme sync script.
1 parent 25fdd98 commit f32bd6f

File tree

4 files changed

+29
-9
lines changed

4 files changed

+29
-9
lines changed

.storybook/preview-head.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
<!-- Or you can load custom head-tag JavaScript: -->
55

6-
<!-- <script
6+
<script
77
src="dist/src/utils/syncTheme.js"
88
type="application/javascript"
9-
></script> -->
9+
></script>
1010

1111
<link rel="preconnect" href="https://fonts.googleapis.com" />
1212
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />

rollup.config.js

+22-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import peerDepsExternal from "rollup-plugin-peer-deps-external";
66
import preserveDirectives from "rollup-plugin-preserve-directives";
77
import { terser } from "rollup-plugin-terser";
88

9-
export default {
9+
export default [{
1010
onwarn(warning, warn) {
1111
if (
1212
warning.code === "MODULE_LEVEL_DIRECTIVE" &&
@@ -39,4 +39,24 @@ export default {
3939
terser({ compress: { directives: false } }),
4040
preserveDirectives(),
4141
],
42-
};
42+
43+
}, {
44+
input: "src/utils/syncTheme.ts",
45+
output: [
46+
{
47+
dir: "dist/src/utils/",
48+
format: "iife",
49+
name: "syncTheme",
50+
},
51+
],
52+
plugins: [
53+
resolve(),
54+
commonjs(),
55+
typescript({
56+
tsconfig: "./tsconfig.json",
57+
outDir: "dist/src/utils/",
58+
declaration: false,
59+
}),
60+
terser(),
61+
],
62+
}];

src/utils/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { clsx, type ClassValue } from "clsx";
22
import { twMerge } from "tailwind-merge";
33
export * from "./darkMode";
4-
// export * from "./syncTheme";
54
export function cn(...inputs: ClassValue[]) {
65
return twMerge(clsx(inputs));
76
}

src/utils/syncTheme.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
// import { theme } from "./darkMode";
1+
import { theme } from "./darkMode"
2+
23
// This script sets up event listeners to set the appropriate css class in the DOM for the current theme. It's intended to be executed in the head of the document hence it is immediately invoked (IIFE).
3-
// (() => {
4-
// theme.syncTheme();
5-
// })();
4+
(() => {
5+
theme.syncTheme()
6+
})()

0 commit comments

Comments
 (0)