mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-25 08:01:20 -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",
|
"video",
|
||||||
"player"
|
"player"
|
||||||
],
|
],
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"import": "./dist/artplayer-plugin-{{name}}.mjs",
|
||||||
|
"require": "./dist/artplayer-plugin-{{name}}.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
"main": "dist/artplayer-plugin-{{name}}.js",
|
"main": "dist/artplayer-plugin-{{name}}.js",
|
||||||
|
"module": "./dist/artplayer-plugin-{{name}}.mjs",
|
||||||
"types": "types/artplayer-plugin-{{name}}.d.ts",
|
"types": "types/artplayer-plugin-{{name}}.d.ts",
|
||||||
"legacy": "dist/artplayer-plugin-{{name}}.legacy.js",
|
"legacy": "dist/artplayer-plugin-{{name}}.legacy.js",
|
||||||
"browserslist": "last 1 Chrome version"
|
"browserslist": "last 1 Chrome version"
|
||||||
|
|||||||
@@ -10,15 +10,20 @@ export default function {{export}}(option) {
|
|||||||
|
|
||||||
if (typeof document !== 'undefined') {
|
if (typeof document !== 'undefined') {
|
||||||
const id = 'artplayer-plugin-{{name}}';
|
const id = 'artplayer-plugin-{{name}}';
|
||||||
const $style = document.getElementById(id);
|
let $style = document.getElementById(id)
|
||||||
if ($style) {
|
if (!$style) {
|
||||||
$style.textContent = style;
|
$style = document.createElement('style')
|
||||||
} else {
|
$style.id = id
|
||||||
const $style = document.createElement('style');
|
if (document.readyState === 'loading') {
|
||||||
$style.id = id;
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
$style.textContent = style;
|
document.head.appendChild($style)
|
||||||
document.head.appendChild($style);
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
(document.head || document.documentElement).appendChild($style)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
$style.textContent = style
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== 'undefined') {
|
||||||
|
|||||||
Reference in new issue
Block a user