Build CSS using Vite

Nikita Karamov 2023-01-25 18:27:00 +01:00
parent e28a7c6f67
commit 8051d2d2e8
No known key found for this signature in database
GPG Key ID: 41D6F71EE78E77CD
4 changed files with 9 additions and 5 deletions

View File

@ -22,7 +22,6 @@
} }
</style> </style>
<link rel="stylesheet" href="./src/shareon.css" />
</head> </head>
<body> <body>

View File

@ -42,9 +42,7 @@
"dist" "dist"
], ],
"scripts": { "scripts": {
"build": "pnpm run build:js && pnpm run build:css", "build": "vite build",
"build:js": "vite build",
"build:css": "postcss src/shareon.css -o dist/shareon.min.css --map",
"dev": "vite", "dev": "vite",
"lint": "prettier --check . && eslint .", "lint": "prettier --check . && eslint .",
"size": "size-limit", "size": "size-limit",
@ -63,7 +61,6 @@
"postcss": "^8.4.19", "postcss": "^8.4.19",
"postcss-banner": "^4.0.1", "postcss-banner": "^4.0.1",
"postcss-calc": "^8.2.4", "postcss-calc": "^8.2.4",
"postcss-cli": "^10.0.0",
"postcss-css-variables": "^0.18.0", "postcss-css-variables": "^0.18.0",
"postcss-csso": "^6.0.1", "postcss-csso": "^6.0.1",
"prettier": "^2.7.1", "prettier": "^2.7.1",

View File

@ -1,3 +1,5 @@
import "./shareon.css";
// prettier-ignore // prettier-ignore
/** /**
* Map of social networks to their respective URL builders. * Map of social networks to their respective URL builders.

View File

@ -15,6 +15,12 @@ export default defineConfig({
}, },
rollupOptions: { rollupOptions: {
output: { 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} */`, banner: `/*! ${package_.name} v${package_.version} */`,
}, },
}, },