-
Notifications
You must be signed in to change notification settings - Fork 28
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
HTML Displays as plain text after build on production server #38
Comments
If there is no error, I would guess that the library is simply not loaded. |
If the library is not loaded, how would the text then just magically come in? PLUGIN
MAIN CODE
CODE TO LOAD AND DISPLAY (widget-code-1.json)
|
Oh, I wasn't paying attention. This is Vue. In that case, I'm not sure. I'd still guess that the library is not loading perhaps some of your imports are failing in production? Check the developer console to make sure all the files are loaded and there are no errors? |
I understand your description of the problem... as I said: Check the developer console to make sure all the files are loaded and there are no errors? This is exactly the behavior one would expect if the library didn't fully load become some of the URLs 404, etc... and I have no idea how you are building or packaging your dependencies, etc. |
I also encountered the same problem. I think this is a bug. How do you solve it? |
Might be, but I have seen no evidence yet that it's a bug. A reproducible example in JSfiddle would go a long way. |
You have to load the highlightjs at the main script, example: main.js or main.ts
|
I have temporarily solved this problem. The reason is that webpack did not pack the unused code when packing, so quotes it here.
|
This is expected behavior as webpack will treeshake unused imports out of the bundle in production. If you are not planning on using import 'highlight.js/lib/common'; // side effect import will not be optimized out by webpack
import hljsVuePlugin from "@highlightjs/vue-plugin";
const app = createApp(App)
app.use(hljsVuePlugin)
app.mount('#app') |
But,I am planning on using hljsCommon object in my code,how should i set? |
You need to provide a minimum reproduction repo as there's not enough information |
On my local PC (localhost - dev server) the code renders 100%
But on our production server (After build) it shows as plain text.
The text was updated successfully, but these errors were encountered: