diff --git a/package.json b/package.json index 3d0f946e..4e998c13 100644 --- a/package.json +++ b/package.json @@ -17,8 +17,9 @@ "start": "next start -p 3000", "start:with-migrate": "npm run db:generate && npm run db:deploy && next start -p 3000", "cp-widget-lang": "mkdir -p public/js/widget/lang && cp -r widget/lang public/js/widget", - "build:widget": "vite build --config vite.widget.config.js && npm run cp-widget-lang", - "build:sdk": "vite build --config vite.sdk.config.js" + "build:widget": "vite build --config vite.widget.config.js && npm run cp-widget-lang && npm run build:iframe", + "build:sdk": "vite build --config vite.sdk.config.js", + "build:iframe": "vite build --config vite.iframe.config.js" }, "prettier": "@egoist/prettier-config", "dependencies": { diff --git a/postcss.config.js b/postcss.config.js index de3b257b..72c558c9 100644 --- a/postcss.config.js +++ b/postcss.config.js @@ -1,7 +1,15 @@ module.exports = { plugins: { tailwindcss: { - prefix: 'comment' + purge: [ + "widget/**/*.svelte" + ], + darkMode: 'class', + variants: { + extend: { + outline: ['dark'] + } + } }, autoprefixer: {}, }, diff --git a/public/doc/advanced/sdk.md b/public/doc/advanced/sdk.md index 6574d6dc..71274f06 100644 --- a/public/doc/advanced/sdk.md +++ b/public/doc/advanced/sdk.md @@ -50,25 +50,3 @@ Render widget to specific DOM element. #### window.CUSDIS.setTheme(theme: 'dark' | 'light' | 'auto') Manually set theme. - -## Style customization - -We use css variables to define our style. Here is the available variables you can override: - -```css -:root { - --cusdis--color-text-default: rgba(0, 0, 0, 0.8); - --cusdis--color-input-border: #ddd; - --cusdis--color-btn-text: rgba(0, 0, 0, 0.8); - --cusdis--color-btn-bg-default: #ddd; - --cusdis--color-btn-bg-disabled: rgba(0, 0, 0, 0.5); - --cusdis--color-btn-border: none; - --cusdis--color-message-text: #fff; - --cusdis--color-message-bg: #046582; - --cusdis--color-pagination-bg-selected: #ddd; - --cusdis--color-comment-indicator-border: #ddd; - --cusdis--color-comment-username-text: #000; - --cusdis--color-mod-text: rgba(0, 0, 0, 0.8); - --cusdis--color-mod-bg: #ddd; -} -``` \ No newline at end of file diff --git a/vite.config.js b/vite.config.js index 6df71384..b3dca3bc 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,6 +1,9 @@ module.exports = { root: "widget", server: { + hmr: { + host: 'localhost' + }, port: 3001, }, plugins: [ diff --git a/vite.iframe.config.js b/vite.iframe.config.js new file mode 100644 index 00000000..1a4357e4 --- /dev/null +++ b/vite.iframe.config.js @@ -0,0 +1,19 @@ +import path from 'path' + +module.exports = { + root: 'widget', + build: { + lib: { + entry: path.resolve(__dirname, 'widget', 'iframe.js'), + name: 'iframe', + fileName: 'iframe', + formats: ['umd'] + }, + outDir: path.resolve(__dirname, 'public', 'js'), + }, + plugins: [ + require('rollup-plugin-svelte')({ + emitCss: false, + }), + ], +} diff --git a/widget/Widget.svelte b/widget/Widget.svelte index 0420eca0..c417fbdc 100644 --- a/widget/Widget.svelte +++ b/widget/Widget.svelte @@ -1,4 +1,5 @@ {#if !error} -