diff --git a/packages/editor/package.json b/packages/editor/package.json index e2628f76..57be1e7e 100644 --- a/packages/editor/package.json +++ b/packages/editor/package.json @@ -6,9 +6,12 @@ "main": "dist/esnext/index.js", "types": "dist/esnext/index.d.ts", "scripts": { - "clean": "rimraf dist", + "clean": "rimraf dist && rimraf public/chartifact", + "copy-assets": "node scripts/copy-assets.js", "dev": "vite --config vite.config.js", "tsc": "tsc -p .", + "predev": "npm run copy-assets", + "postbundle": "npm run copy-assets", "bundle": "vite build --config vite.bundle.config.js", "build": "npm run tsc", "build:06": "npm run build" diff --git a/packages/editor/scripts/copy-assets.js b/packages/editor/scripts/copy-assets.js new file mode 100644 index 00000000..546dafd6 --- /dev/null +++ b/packages/editor/scripts/copy-assets.js @@ -0,0 +1,31 @@ +import fs from 'fs'; +import path from 'path'; + +const sourceDir = '../../docs/dist/v1'; +const targetDir = 'public/chartifact/dist/v1'; + +// Check if source exists +if (!fs.existsSync(sourceDir)) { + console.log('Assets not found, run npm run build in workspace root first'); + process.exit(0); +} + +// Create target directory +fs.mkdirSync(targetDir, { recursive: true }); + +// Copy all files (skip directories) +const files = fs.readdirSync(sourceDir); +let copiedCount = 0; + +files.forEach(file => { + const sourcePath = path.join(sourceDir, file); + const targetPath = path.join(targetDir, file); + + // Only copy if it's a file (not a directory) + if (fs.statSync(sourcePath).isFile()) { + fs.copyFileSync(sourcePath, targetPath); + copiedCount++; + } +}); + +console.log(`Copied ${copiedCount} assets to ${targetDir}`);