From 1550573923e8a59c1b94b7a2a34d4eeb9cdde26b Mon Sep 17 00:00:00 2001 From: Nikita Karamov Date: Wed, 25 Jan 2023 18:27:00 +0100 Subject: [PATCH] Build CSS using Vite --- index.html | 1 - package.json | 5 +---- src/shareon.js | 2 ++ vite.config.js | 6 ++++++ 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index c13f161..691806a 100644 --- a/index.html +++ b/index.html @@ -22,7 +22,6 @@ } - diff --git a/package.json b/package.json index 1649f66..0ccf4ab 100644 --- a/package.json +++ b/package.json @@ -42,9 +42,7 @@ "dist" ], "scripts": { - "build": "pnpm run build:js && pnpm run build:css", - "build:js": "vite build", - "build:css": "postcss src/shareon.css -o dist/shareon.min.css --map", + "build": "vite build", "dev": "vite", "lint": "prettier --check . && eslint .", "size": "size-limit", @@ -63,7 +61,6 @@ "postcss": "^8.4.19", "postcss-banner": "^4.0.1", "postcss-calc": "^8.2.4", - "postcss-cli": "^10.0.0", "postcss-css-variables": "^0.18.0", "postcss-csso": "^6.0.1", "prettier": "^2.7.1", diff --git a/src/shareon.js b/src/shareon.js index bb6a19d..399197e 100644 --- a/src/shareon.js +++ b/src/shareon.js @@ -1,3 +1,5 @@ +import "./shareon.css"; + // prettier-ignore /** * Map of social networks to their respective URL builders. diff --git a/vite.config.js b/vite.config.js index 3fe4dea..680ff86 100644 --- a/vite.config.js +++ b/vite.config.js @@ -15,6 +15,12 @@ export default defineConfig({ }, rollupOptions: { output: { + // Workaround for a correct file name + // See: https://github.com/vitejs/vite/issues/4863 + assetFileNames: (assetInfo) => { + if (assetInfo.name === "style.css") return "shareon.min.css"; + return assetInfo.name; + }, banner: `/*! ${package_.name} v${package_.version} */`, }, },