feat!: inject style via constructable CSSStyleSheet and remove CSP entry (#847)

* chore: not inject inline css on server

* feat!: remove csp entry

* keep csp title in readme

* chore: switch to rolldown and tsdown

* update

* dedupe

* update according to review

* emphasize "both" in csp section

* load css with unplugin-raw

* change tsdown entry
This commit is contained in:
Yue JIN
2025-08-05 12:15:21 +08:00
committed by GU Yiling
parent a6ad4e70a2
commit 7e49190f95
12 changed files with 687 additions and 702 deletions

View File

@ -41,7 +41,7 @@ import type {
} from "./types";
import type { EChartsElement } from "./wc";
import "./style.css";
import "./style.ts";
const wcRegistered = register();

View File

@ -1,6 +1 @@
x-vue-echarts {
display: block;
width: 100%;
height: 100%;
min-width: 0;
}
x-vue-echarts{display:block;width:100%;height:100%;min-width:0;}

16
src/style.ts Normal file
View File

@ -0,0 +1,16 @@
import cssRules from "./style.css?raw";
if (typeof document !== "undefined") {
if (
Array.isArray(document.adoptedStyleSheets) &&
"replaceSync" in CSSStyleSheet.prototype
) {
const sheet = new CSSStyleSheet();
sheet.replaceSync(cssRules);
document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];
} else {
const styleEl = document.createElement("style");
styleEl.textContent = cssRules;
document.head.appendChild(styleEl);
}
}