Closed libsgh closed 1 year ago
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)
. . .
I wonder if import hljs from 'highlight.js/lib/common'
would work?
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
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.
Dev works fine, but when i use
vite build
, andvite preview
, it doesn't show any style, and no error output.