a7650 / vue3-draggable-resizable

[Vue3 组件] 用于拖拽调整位置和大小的的组件,同时支持元素吸附对齐,实时参考线。
MIT License
631 stars 126 forks source link

vite项目有办法通过打包js文件的方式来引入吗? #87

Open YUST2020 opened 1 year ago

YUST2020 commented 1 year ago

使用webpack的vue3项目可以直接使用npm run build打包出来的js没有异常,但该文件引入vite项目会报错‘require is not defined’ 在该项目中引入vite进行打包 vite.config.js `import { fileURLToPath, URL } from 'node:url' import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/ export default defineConfig({ plugins: [ vue() ], build: { lib: { entry: fileURLToPath(new URL('src/index.ts', import.meta.url)), name: 'vdr', formats: ['es'], fileName: () => vdr.js } }, }) ` 打包出来后样式初始大小等均正常,但拖拽和缩放都失效了,请问这个问题有办法解决吗?