Skip to content

Commit

Permalink
fix missing CSS in components
Browse files Browse the repository at this point in the history
See vitejs/vite#12385 for the concrete problem.
We bypass it by loading the main CSS file in any component that needs
global styles.
  • Loading branch information
Boldewyn committed Mar 13, 2023
1 parent fd7e23f commit 04a2b39
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion codepoints.net/views/partials/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<link rel="author" href="/humans.txt">
<link rel="preload" href="<?= static_url('src/fonts/Literata.woff2') ?>" as="font" crossOrigin="anonymous">
<link rel="preload" href="<?= static_url('src/fonts/Literata-Italic.woff2') ?>" as="font" crossOrigin="anonymous">
<link rel="stylesheet" href="<?= static_url('src/css/main.css') ?>">
<link rel="stylesheet" href="<?= static_url('src/css/main.css') ?>" id="main-css">
<link rel="stylesheet" media="print" href="<?= static_url('src/css/print.css') ?>">
<?php include 'head-multilang.php' ?>
<?php if (isset($head_extra)) { echo $head_extra; } ?>
Expand Down
2 changes: 0 additions & 2 deletions src/css/shadow.css

This file was deleted.

3 changes: 1 addition & 2 deletions src/js/components/cp-btn-share.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {LitElement, css, html, unsafeCSS} from 'lit';
import {customElement} from 'lit/decorators.js';
import {gettext as _} from '../_i18n.ts';
import {CpDialog} from './cp-dialog.ts';
import ShadowCSS from '../../css/shadow.css?url';

const services = {
Whatsapp: 'whatsapp://send?text={title}%20{url}',
Expand Down Expand Up @@ -95,7 +94,7 @@ class CpShareContainer extends LitElement {
s.push(html`<li><a class="btn" href="${url}" target="_blank">${service}</a></li>`);
}
return html`
<link rel="stylesheet" href="${ShadowCSS}">
<link rel="stylesheet" href="${document.getElementById('main-css').href}">
<div class="preview">
<span class="url">${this.url}</span>
<span class="title">${this.title}</span>
Expand Down
2 changes: 1 addition & 1 deletion vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default defineConfig({
entryFileNames: '[name]-[hash].js',
assetFileNames: 'assets/[name]-[hash][extname]',
},
}
},
},
css: {
postcss: {
Expand Down

0 comments on commit 04a2b39

Please sign in to comment.