From c219acf10f1036ac53b52def9122b94b80264b25 Mon Sep 17 00:00:00 2001 From: wan92hen Date: Fri, 20 Sep 2024 14:59:45 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=8B=86=E5=88=86CSS=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E4=BC=98=E5=8C=96=E6=96=87=E4=BB=B6=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.ts | 5 ----- src/styles/font-pixel.scss | 4 ++++ src/styles/main.scss | 5 ----- src/styles/style.scss | 6 ++++++ templates/modules/layout.html | 18 +++++++++++------- vite.config.ts | 17 ++++++++++++----- 6 files changed, 33 insertions(+), 22 deletions(-) create mode 100644 src/styles/font-pixel.scss diff --git a/src/main.ts b/src/main.ts index 648fbb3..4ef3636 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,8 +1,3 @@ -import "./styles/tailwind.css"; -import "./styles/style.scss"; -import "./styles/theme.scss"; -import "./styles/font-hack.scss"; - import Alpine from "alpinejs"; import upvote from "./upvote"; import * as tocbot from 'tocbot'; diff --git a/src/styles/font-pixel.scss b/src/styles/font-pixel.scss new file mode 100644 index 0000000..c477011 --- /dev/null +++ b/src/styles/font-pixel.scss @@ -0,0 +1,4 @@ + @font-face { + font-family: Ark-Pixel-12-proportional-zh_cn; + src: url("../fonts/fusion-pixel-12px-proportional-zh_hans.woff2"); +} diff --git a/src/styles/main.scss b/src/styles/main.scss index 8b36901..58fbd50 100644 --- a/src/styles/main.scss +++ b/src/styles/main.scss @@ -10,11 +10,6 @@ html { box-sizing: inherit; } -@font-face { - font-family: Ark-Pixel-12-proportional-zh_cn; - src: url("../fonts/fusion-pixel-12px-proportional-zh_hans.woff2"); -} - body { margin: 0; padding: 0; diff --git a/src/styles/style.scss b/src/styles/style.scss index dd57a6a..46b1935 100644 --- a/src/styles/style.scss +++ b/src/styles/style.scss @@ -1,3 +1,7 @@ +@tailwind base; +@tailwind utilities; +@tailwind components; + @import 'buttons'; @import 'header'; @import 'logo'; @@ -6,3 +10,5 @@ @import 'pagination'; @import 'footer'; @import 'typed-text'; + +@import 'theme'; \ No newline at end of file diff --git a/templates/modules/layout.html b/templates/modules/layout.html index 0e62a6b..a5c8a67 100644 --- a/templates/modules/layout.html +++ b/templates/modules/layout.html @@ -5,13 +5,17 @@ - - - + + + + + + + diff --git a/vite.config.ts b/vite.config.ts index 2b5614d..4cec3b8 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -4,15 +4,22 @@ import path from "path"; import PurgeIcons from "vite-plugin-purge-icons"; export default defineConfig({ + base: "", plugins: [PurgeIcons()], build: { outDir: fileURLToPath(new URL("./templates/assets/dist", import.meta.url)), emptyOutDir: true, - lib: { - entry: path.resolve(__dirname, "src/main.ts"), - name: "main", - fileName: "main", - formats: ["iife"], + rollupOptions: { + input: { + main: path.resolve(__dirname, "src/main.ts"), + style: path.resolve(__dirname, "src/styles/style.scss"), + fontHack: path.resolve(__dirname, "src/styles/font-hack.scss"), + fontPixel: path.resolve(__dirname, "src/styles/font-pixel.scss"), + }, + output: { + entryFileNames: "[name].js", + assetFileNames: "[name].[ext]", + }, }, }, });