Skip to content

Commit

Permalink
Fix css loading order in head (#2785)
Browse files Browse the repository at this point in the history
The `custom.css` file should be loaded last to take precedence over the
default file. Otherwise, the theming will not work as expected, and you
would have to use `!important` most of the time.
  • Loading branch information
xoxys authored Nov 9, 2023
1 parent 6f07f2a commit 65a93ca
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
1 change: 0 additions & 1 deletion web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<meta name="theme-color" content="#65a30d" />
<title>Woodpecker</title>
<script type="" src="/web-config.js"></script>
<link rel="stylesheet" href="/assets/custom.css" />
</head>
<body>
<div id="app"></div>
Expand Down
19 changes: 19 additions & 0 deletions web/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,24 @@ function woodpeckerInfoPlugin() {
};
}

function externalCSSPlugin() {
return {
name: 'external-css',
transformIndexHtml: {
enforce: 'post',
transform() {
return [
{
tag: 'link',
attrs: { rel: 'stylesheet', type: 'text/css', href: '/assets/custom.css' },
injectTo: 'head',
},
];
},
},
};
}

// https://vitejs.dev/config/
export default defineConfig({
plugins: [
Expand Down Expand Up @@ -93,6 +111,7 @@ export default defineConfig({
Components({
resolvers: [IconsResolver()],
}),
externalCSSPlugin(),
woodpeckerInfoPlugin(),
prismjs({
languages: ['yaml'],
Expand Down

0 comments on commit 65a93ca

Please sign in to comment.