Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
YUST2020 opened this issue Jan 13, 2023 · 0 comments
Open

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

YUST2020 opened this issue Jan 13, 2023 · 0 comments

Comments

@YUST2020
Copy link

使用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
}
},
})
`
打包出来后样式初始大小等均正常,但拖拽和缩放都失效了,请问这个问题有办法解决吗?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant