mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-08 10:56:15 -08:00
feat: add module and exports fields in package.json; improve style handling in index.js
This commit is contained in:
1 parent
241b4f3ee3
commit
50320bad5d
2 files changed
+20
-8
No files matched your search
@@ -17,7 +17,14 @@
|
||||
"video",
|
||||
"player"
|
||||
],
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./dist/artplayer-plugin-{{name}}.mjs",
|
||||
"require": "./dist/artplayer-plugin-{{name}}.js"
|
||||
}
|
||||
},
|
||||
"main": "dist/artplayer-plugin-{{name}}.js",
|
||||
"module": "./dist/artplayer-plugin-{{name}}.mjs",
|
||||
"types": "types/artplayer-plugin-{{name}}.d.ts",
|
||||
"legacy": "dist/artplayer-plugin-{{name}}.legacy.js",
|
||||
"browserslist": "last 1 Chrome version"
|
||||
|
||||
@@ -10,15 +10,20 @@ export default function {{export}}(option) {
|
||||
|
||||
if (typeof document !== 'undefined') {
|
||||
const id = 'artplayer-plugin-{{name}}';
|
||||
const $style = document.getElementById(id);
|
||||
if ($style) {
|
||||
$style.textContent = style;
|
||||
} else {
|
||||
const $style = document.createElement('style');
|
||||
$style.id = id;
|
||||
$style.textContent = style;
|
||||
document.head.appendChild($style);
|
||||
let $style = document.getElementById(id)
|
||||
if (!$style) {
|
||||
$style = document.createElement('style')
|
||||
$style.id = id
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
document.head.appendChild($style)
|
||||
})
|
||||
}
|
||||
else {
|
||||
(document.head || document.documentElement).appendChild($style)
|
||||
}
|
||||
}
|
||||
$style.textContent = style
|
||||
}
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
|
||||
Reference in new issue
Block a user