diff --git a/.github/workflows/website.yaml b/.github/workflows/website.yaml index b72dc83a..11edbe63 100644 --- a/.github/workflows/website.yaml +++ b/.github/workflows/website.yaml @@ -24,10 +24,7 @@ jobs: uses: ./.github/actions/setup - name: Build - run: pnpm run build - - - name: Build packages - run: pnpm run dist + run: pnpm run build react - name: Build website run: ./node_modules/.bin/next build diff --git a/bin/build/targets/vue/index.js b/bin/build/targets/vue/index.js index f1bc47f4..bef8980f 100644 --- a/bin/build/targets/vue/index.js +++ b/bin/build/targets/vue/index.js @@ -1,7 +1,10 @@ +import vue from '@vitejs/plugin-vue'; import { fromHtml } from 'hast-util-from-html'; import { toHtml } from 'hast-util-to-html'; import fs from 'node:fs/promises'; import path from 'node:path'; +import { build } from 'vite'; +import dts from 'vite-plugin-dts'; import { generateExport } from '../../lib/import-export.js'; import iconTemplate from './template.js'; @@ -68,5 +71,31 @@ export default async (ctx, target) => { promises.push(fs.writeFile(path.join(outDir, 'index.ts'), mainIndexContent)); - return Promise.all(promises); + await Promise.all(promises); + + return build({ + root: target.path, + logLevel: 'silent', + build: { + outDir: 'dist', + lib: { + entry: path.join('src', 'index.ts'), + fileName: (format, name) => + format === 'cjs' ? `${name}.js` : `esm/${name}.mjs`, + formats: ['cjs', 'es'], + }, + rollupOptions: { + external: ['vue-demi', 'vue'], + }, + }, + optimizeDeps: { + exclude: ['vue-demi'], + }, + plugins: [ + vue({ + isProduction: true, + }), + dts(), + ], + }); }; diff --git a/examples/next/public/next.svg b/examples/next/public/next.svg deleted file mode 100644 index 5174b28c..00000000 --- a/examples/next/public/next.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/next/public/vercel.svg b/examples/next/public/vercel.svg deleted file mode 100644 index d2f84222..00000000 --- a/examples/next/public/vercel.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/package.json b/package.json index 83ae81c2..bc06ae6f 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,6 @@ ], "scripts": { "build": "node ./bin/build/index.js", - "dist": "pnpm --filter './packages/**' run dist", "lint": "eslint .", "lint:fix": "pnpm run lint --fix", "prepublish-all": "node ./bin/prepublish.js" @@ -43,6 +42,7 @@ "@svgr/babel-plugin-remove-jsx-attribute": "^8.0.0", "@svgr/core": "^8.1.0", "@svgr/plugin-jsx": "^8.1.0", + "@vitejs/plugin-vue": "^4.4.0", "esbuild": "^0.19.5", "eslint": "^8.52.0", "eslint-config-prettier": "^9.0.0", @@ -53,7 +53,9 @@ "prettier": "^3.0.3", "scule": "^1.0.0", "semver": "^7.5.4", - "typescript": "^5.2.2" + "typescript": "^5.2.2", + "vite": "^4.5.0", + "vite-plugin-dts": "^3.6.2" }, "packageManager": "pnpm@8.10.0" } diff --git a/packages/iconoir-vue/package.json b/packages/iconoir-vue/package.json index d90dd0be..1c67817f 100644 --- a/packages/iconoir-vue/package.json +++ b/packages/iconoir-vue/package.json @@ -39,18 +39,10 @@ "files": [ "dist" ], - "scripts": { - "dist": "vite build", - "prepublishOnly": "npm run dist" - }, "dependencies": { "vue-demi": "^0.14.6" }, "devDependencies": { - "@vitejs/plugin-vue": "^4.4.0", - "terser": "^5.22.0", - "vite": "^4.5.0", - "vite-plugin-dts": "^3.6.2", "vue": "^3.3.7" }, "peerDependencies": { diff --git a/packages/iconoir-vue/vite.config.ts b/packages/iconoir-vue/vite.config.ts deleted file mode 100644 index 744391a0..00000000 --- a/packages/iconoir-vue/vite.config.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { defineConfig } from 'vite'; -import vue from '@vitejs/plugin-vue'; -import dts from 'vite-plugin-dts'; -import path from 'path'; -import fs from 'fs'; - -export default () => { - const filenames = fs.readdirSync(path.resolve(process.cwd(), 'src')); - const cwd = process.cwd(); - - return defineConfig({ - build: { - outDir: 'dist', - minify: 'terser', - lib: { - entry: filenames.map((name) => path.resolve(cwd, `src/${name}`)), - fileName: (format, name) => - format === 'cjs' ? `${name}.js` : `esm/${name}.mjs`, - formats: ['cjs', 'es'], - }, - rollupOptions: { - external: ['vue-demi', 'vue'], - }, - }, - optimizeDeps: { - exclude: ['vue-demi'], - }, - plugins: [ - vue({ - isProduction: true, - }), - dts(), - ], - }); -}; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 40c65111..ac579836 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -20,6 +20,9 @@ importers: '@svgr/plugin-jsx': specifier: ^8.1.0 version: 8.1.0(@svgr/core@8.1.0) + '@vitejs/plugin-vue': + specifier: ^4.4.0 + version: 4.4.0(vite@4.5.0)(vue@3.3.7) esbuild: specifier: ^0.19.5 version: 0.19.5 @@ -53,6 +56,12 @@ importers: typescript: specifier: ^5.2.2 version: 5.2.2 + vite: + specifier: ^4.5.0 + version: 4.5.0(terser@5.22.0) + vite-plugin-dts: + specifier: ^3.6.2 + version: 3.6.2(typescript@5.2.2)(vite@4.5.0) examples/next: dependencies: @@ -254,23 +263,11 @@ importers: version: 1.7.2(vue@3.3.7) vue-demi: specifier: ^0.14.6 - version: 0.14.6(@vue/composition-api@1.7.2)(vue@3.3.7) + version: 0.14.6(vue@3.3.7) devDependencies: - '@vitejs/plugin-vue': - specifier: ^4.4.0 - version: 4.4.0(vite@4.5.0)(vue@3.3.7) - terser: - specifier: ^5.22.0 - version: 5.22.0 - vite: - specifier: ^4.5.0 - version: 4.5.0(terser@5.22.0) - vite-plugin-dts: - specifier: ^3.6.2 - version: 3.6.2(typescript@5.2.2)(vite@4.5.0) vue: specifier: ^3.3.7 - version: 3.3.7(typescript@5.2.2) + version: 3.3.7 packages: @@ -3437,7 +3434,7 @@ packages: vite: ^4.0.0 vue: ^3.2.25 dependencies: - vite: 4.5.0(@types/node@18.18.7) + vite: 4.5.0(terser@5.22.0) vue: 3.3.7(typescript@5.2.2) dev: true @@ -3555,7 +3552,7 @@ packages: dependencies: '@vue/compiler-ssr': 3.3.7 '@vue/shared': 3.3.7 - vue: 3.3.7(typescript@5.2.2) + vue: 3.3.7 /@vue/shared@3.3.7: resolution: {integrity: sha512-N/tbkINRUDExgcPTBvxNkvHGu504k8lzlNQRITVnm6YjOjwa4r0nnbd4Jb01sNpur5hAllyRJzSK5PvB9PPwRg==} @@ -9717,7 +9714,7 @@ packages: /vlq@1.0.1: resolution: {integrity: sha512-gQpnTgkubC6hQgdIcRdYGDSDc+SaujOdyesZQMv6JlfQee/9Mp0Qhnys6WxDWvQnL5WZdT7o2Ul187aSt0Rq+w==} - /vue-demi@0.14.6(@vue/composition-api@1.7.2)(vue@3.3.7): + /vue-demi@0.14.6(vue@3.3.7): resolution: {integrity: sha512-8QA7wrYSHKaYgUxDA5ZC24w+eHm3sYCbp0EzcDwKqN3p6HqtTCGR/GVsPyZW92unff4UlcSh++lmqDWN3ZIq4w==} engines: {node: '>=12'} hasBin: true @@ -9729,8 +9726,7 @@ packages: '@vue/composition-api': optional: true dependencies: - '@vue/composition-api': 1.7.2(vue@3.3.7) - vue: 3.3.7(typescript@5.2.2) + vue: 3.3.7 dev: false /vue-template-compiler@2.7.15: @@ -9752,6 +9748,20 @@ packages: typescript: 5.2.2 dev: true + /vue@3.3.7: + resolution: {integrity: sha512-YEMDia1ZTv1TeBbnu6VybatmSteGOS3A3YgfINOfraCbf85wdKHzscD6HSS/vB4GAtI7sa1XPX7HcQaJ1l24zA==} + peerDependencies: + typescript: '*' + peerDependenciesMeta: + typescript: + optional: true + dependencies: + '@vue/compiler-dom': 3.3.7 + '@vue/compiler-sfc': 3.3.7 + '@vue/runtime-dom': 3.3.7 + '@vue/server-renderer': 3.3.7(vue@3.3.7) + '@vue/shared': 3.3.7 + /vue@3.3.7(typescript@5.2.2): resolution: {integrity: sha512-YEMDia1ZTv1TeBbnu6VybatmSteGOS3A3YgfINOfraCbf85wdKHzscD6HSS/vB4GAtI7sa1XPX7HcQaJ1l24zA==} peerDependencies: