diff --git a/package-lock.json b/package-lock.json index 22678633..3c3a4e4f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,7 +33,6 @@ "vite-plugin-banner": "^0.8.0", "vite-plugin-compression": "^0.5.1", "vite-plugin-html": "^3.2.2", - "vite-plugin-static-copy": "^2.0.0", "zod": "^3.23.8", "zod-to-json-schema": "^3.23.5" } @@ -2414,20 +2413,6 @@ "dev": true, "license": "MIT" }, - "node_modules/anymatch": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", - "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", - "dev": true, - "license": "ISC", - "dependencies": { - "normalize-path": "^3.0.0", - "picomatch": "^2.0.4" - }, - "engines": { - "node": ">= 8" - } - }, "node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", @@ -2533,19 +2518,6 @@ "dev": true, "license": "Apache-2.0" }, - "node_modules/binary-extensions": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", - "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/boolbase": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", @@ -2662,31 +2634,6 @@ "node": ">=10" } }, - "node_modules/chokidar": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", - "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", - "dev": true, - "license": "MIT", - "dependencies": { - "anymatch": "~3.1.2", - "braces": "~3.0.2", - "glob-parent": "~5.1.2", - "is-binary-path": "~2.1.0", - "is-glob": "~4.0.1", - "normalize-path": "~3.0.0", - "readdirp": "~3.6.0" - }, - "engines": { - "node": ">= 8.10.0" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - }, - "optionalDependencies": { - "fsevents": "~2.3.2" - } - }, "node_modules/clean-css": { "version": "5.3.3", "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-5.3.3.tgz", @@ -5147,19 +5094,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-binary-path": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", - "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", - "dev": true, - "license": "MIT", - "dependencies": { - "binary-extensions": "^2.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/is-boolean-object": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.2.tgz", @@ -6401,16 +6335,6 @@ "node": "^16.14.0 || >=18.0.0" } }, - "node_modules/normalize-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/normalize-url": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-8.0.1.tgz", @@ -10665,19 +10589,6 @@ "util-deprecate": "~1.0.1" } }, - "node_modules/readdirp": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", - "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", - "dev": true, - "license": "MIT", - "dependencies": { - "picomatch": "^2.2.1" - }, - "engines": { - "node": ">=8.10.0" - } - }, "node_modules/regexp.prototype.flags": { "version": "1.5.3", "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.3.tgz", @@ -13014,25 +12925,6 @@ "node": ">=12" } }, - "node_modules/vite-plugin-static-copy": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/vite-plugin-static-copy/-/vite-plugin-static-copy-2.1.0.tgz", - "integrity": "sha512-n8lEOIVM00Y/zronm0RG8RdPyFd0SAAFR0sii3NWmgG3PSCyYMsvUNRQTlb3onp1XeMrKIDwCrPGxthKvqX9OQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "chokidar": "^3.5.3", - "fast-glob": "^3.2.11", - "fs-extra": "^11.1.0", - "picocolors": "^1.0.0" - }, - "engines": { - "node": "^18.0.0 || >=20.0.0" - }, - "peerDependencies": { - "vite": "^5.0.0" - } - }, "node_modules/w3c-xmlserializer": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-5.0.0.tgz", diff --git a/package.json b/package.json index 66ffa4d0..3e3cc77a 100644 --- a/package.json +++ b/package.json @@ -69,6 +69,7 @@ "prebuild": "npm run build:lib", "postbuild": "npm run generate:jsonSchema", "build:demo": "vite build --mode demo", + "postbuild:demo": "node tools/copy-assets.mjss", "build:demo:watch": "vite build --mode demo --watch", "build:icons": "node ./tools/generate-sprite", "lint": "eslint ./src --ext .js || true", @@ -103,7 +104,6 @@ "vite-plugin-banner": "^0.8.0", "vite-plugin-compression": "^0.5.1", "vite-plugin-html": "^3.2.2", - "vite-plugin-static-copy": "^2.0.0", "zod": "^3.23.8", "zod-to-json-schema": "^3.23.5" }, diff --git a/tools/generate-json-schema.ts b/tools/generate-json-schema.ts index c24baa20..ed7aedb2 100644 --- a/tools/generate-json-schema.ts +++ b/tools/generate-json-schema.ts @@ -1,9 +1,11 @@ -import { join } from 'node:path' +import { join, dirname, resolve } from 'node:path' import { writeFileSync } from 'node:fs' +import { fileURLToPath } from 'node:url'; import { z } from 'zod' import { zodToJsonSchema } from 'zod-to-json-schema' -const __dirname = join(new URL('.', import.meta.url).pathname) +const __dirname = dirname(fileURLToPath(import.meta.url)); +const projectRoot = resolve(__dirname, '..'); const htmlAttributesSchema = z.record( z.string(), @@ -168,5 +170,5 @@ const reorderSchema = (schema: object) => { const jsonSchema = zodToJsonSchema(formDataSchema, { name: 'formData', nameStrategy: 'title' }) const orderedJsonSchema = reorderSchema(jsonSchema) -const distDir = join(__dirname, '../dist') +const distDir = join(projectRoot, 'dist') writeFileSync(join(distDir, 'formData_schema.json'), JSON.stringify(orderedJsonSchema, null, 2)) diff --git a/vite.config.js b/vite.config.js index 53f443f6..43e505cc 100644 --- a/vite.config.js +++ b/vite.config.js @@ -3,7 +3,6 @@ import { defineConfig } from 'vite' import { languageFileOptions, enUS } from '@draggable/formeo-languages' import banner from 'vite-plugin-banner' import compression from 'vite-plugin-compression' -import { viteStaticCopy } from 'vite-plugin-static-copy' import { createHtmlPlugin } from 'vite-plugin-html' import pkg from './package.json' @@ -103,35 +102,5 @@ export default defineConfig({ ext: '.gz', threshold: 10240, }), - viteStaticCopy({ - targets: [ - { - src: resolve('src/lib/icons/formeo-sprite.svg'), - dest: './assets/img/', - }, - { - src: resolve('src/lib/icons/formeo-sprite.svg'), - dest: resolve('dist/'), - }, - { - src: resolve('node_modules', '@draggable/formeo-languages/dist/lang/*'), - dest: './assets/lang', - }, - { - src: resolve('dist/formeo.umd.js'), - dest: './assets/js/', - rename: 'formeo.min.js', - }, - { - src: resolve('dist/formeo.umd.js'), - dest: resolve('dist/'), - rename: 'formeo.min.js', - }, - { - src: resolve('dist/formeo.min.css'), - dest: './assets/css/', - }, - ], - }), ], })