chore: unify build output for both npm and bundle

This commit is contained in:
2026-04-26 23:02:36 +03:30
parent 5fd8f9b047
commit 8134911e17
5 changed files with 1104 additions and 29 deletions

2
.gitignore vendored
View File

@@ -3,8 +3,8 @@ node_modules/
# Build outputs
dist/
dist-ssr/
bundle/
types/
*.local
# TypeScript cache

1076
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,25 +1,34 @@
{
"name": "VideoPlayer",
"version": "0.0.1",
"description": "VideoPlayer (vp) is a private project at db company to handle hls streams in a modular beautiful html5 video player.",
"keywords": [],
"repository": {
"type": "git",
"url": "VideoPlayer"
"name": "@db/VP",
"version": "0.0.2",
"type": "module",
"main": "./dist/video-player.cjs.js",
"module": "./dist/video-player.es.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"import": "./dist/video-player.es.js",
"require": "./dist/video-player.cjs.js",
"types": "./dist/index.d.ts"
},
"license": "MIT",
"author": "db",
"type": "commonjs",
"main": "index.ts",
"./style.css": "./dist/style.css"
},
"files": [
"dist",
"README.md"
],
"scripts": {
"dev": "vite build --watch",
"build": "tsc",
"bundle": "vite build",
"test": "vitest",
"preview": "vite preview"
"build": "tsc && vite build",
"test": "vitest run",
"test:watch": "vitest",
"lint": "eslint . --ext .ts",
"preview": "vite preview",
"prepublishOnly": "npm run lint && npm run test && npm run build"
},
"devDependencies": {
"@types/node": "^25.6.0",
"eslint": "^9.39.4",
"typescript": "^6.0.3",
"vite": "^8.0.9",
"vitest": "^4.1.5"

View File

@@ -2,15 +2,15 @@
"compilerOptions": {
"target": "ES2020",
"module": "ESNext",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"strict": true,
"declaration": true,
"emitDeclarationOnly": true,
"outDir": "./dist",
"rootDir": "./src",
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
"include": ["src"],
"exclude": ["node_modules", "dist", "bundle"]
}

View File

@@ -1,16 +1,16 @@
import { defineConfig } from "vite";
import { resolve } from "path";
export default defineConfig({
build: {
lib: {
entry: resolve(__dirname, "src/index.ts"),
entry: "src/index.ts",
name: "VP",
fileName: (format) => `video-player.${format}.js`,
formats: ["es", "umd"],
formats: ["es", "cjs", "umd"],
},
outDir: "bundle",
emptyOutDir: true,
minify: "esbuild",
outDir: "dist",
emptyOutDir: false,
rollupOptions: {
external: ["hls.js"],
output: {