-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathrolldown.config.ts
More file actions
36 lines (29 loc) · 1.04 KB
/
Copy pathrolldown.config.ts
File metadata and controls
36 lines (29 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { defineConfig } from "tsdown";
import fs from "fs";
import path from "path";
import { fileURLToPath } from "url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
// This is our custom plugin object
const copyCssPlugin = {
name: "copy-css",
// This function runs after the bundle is written to the dist folder
writeBundle() {
const source = path.resolve(__dirname, "node_modules/plyr/dist/plyr.css");
const destinationDir = path.resolve(__dirname, "dist");
const destinationFile = path.join(destinationDir, "plyr.css");
// Ensure the 'dist' directory exists. The recursive option prevents errors if it already exists.
fs.mkdirSync(destinationDir, { recursive: true });
// Copy the file
fs.copyFileSync(source, destinationFile);
console.log("✅ Copied plyr.css to dist/plyr.css");
},
};
export default defineConfig({
entry: ["src/index.tsx"],
format: ["esm", "cjs"],
dts: true,
sourcemap: true,
// Use our custom plugin
plugins: [copyCssPlugin],
});