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

Does the plugin support vite v3.1.9? #43

Closed
libsgh opened this issue Jan 3, 2023 · 5 comments
Closed

Does the plugin support vite v3.1.9? #43

libsgh opened this issue Jan 3, 2023 · 5 comments

Comments

@libsgh
Copy link

libsgh commented Jan 3, 2023

Dev works fine, but when i use vite build, andvite preview, it doesn't show any style, and no error output.

import 'highlight.js/styles/atom-one-light.css'
import 'highlight.js/lib/common'
import hljsVuePlugin from "@highlightjs/vue-plugin"
export default({
  name: "code",
  components:{
    highlightjs: hljsVuePlugin.component
  }
})

image

@xiaomaiyun
Copy link

xiaomaiyun commented Jan 3, 2023

#38

@xiaomaiyun
Copy link

I have temporarily solved this problem. The reason is that webpack did not pack the unused code when packing, so quotes it here.

import 'highlight.js/styles/atom-one-dark.css'
import hljsCommon from 'highlight.js/lib/common'
import hljsVuePlugin from '@highlightjs/vue-plugin'
. . . 
const app = createApp(App)
. . .
// 注意:解决Vue使用highlight.js build打包发布后样式消失问题,原因是webpack在打包的时候没有把未被使用的代码打包进去,因此,在此处引用一下,看似无意义实则有用
hljsCommon.highlightAuto('<h1>Highlight.js has been registered successfully!</h1>').value
app.use(hljsVuePlugin)
. . .

@joshgoebel
Copy link
Member

I wonder if import hljs from 'highlight.js/lib/common' would work?

@xiaomaiyun
Copy link

I wonder if import hljs from 'highlight.js/lib/common' would work?

hljsCommon.highlightAuto('<h1>Highlight.js has been registered successfully!</h1>').value

work,if this code

@libsgh
Copy link
Author

libsgh commented Jan 4, 2023

I wonder if import hljs from 'highlight.js/lib/common' would work?

hljsCommon.highlightAuto('<h1>Highlight.js has been registered successfully!</h1>').value

work,if this code

It's work for me, thanks.

@libsgh libsgh closed this as completed Jan 4, 2023
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

3 participants