-
-
Notifications
You must be signed in to change notification settings - Fork 385
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
Syntax highlighting not working with webpack v4 #86
Comments
Hello, I have encounted the problem, too. But it doesn't work by using the methods you provide ( webpack4.22.0 ). |
If you modify So, copy the those two files out of your import VueCodemirror from 'vue-codemirror'
import 'codemirror/lib/codemirror.css' to this: import { codemirror } from '@/components/vue-codemirror'
import 'codemirror/lib/codemirror.css' |
Also experiencing the same, anyone managed to solve this? |
I found simpler solution, without custom component. import { codemirror } from 'vue-codemirror'
import 'codemirror/mode/javascript/javascript' But custom component is needed for using inside Electron. |
If using Electron-Vue, add |
adding below to package.json fixed it. also check white-listing-externals
|
I tried the above methods, and finally found that all I need to do is: |
For me , I use : |
Thanks, @ROTGP, it worked! vue: 2.6.11 |
if anyone is using nuxt, try to add it to the config file
|
BUG REPORT TEMPLATE
I think this issue is affecting vue-codemirror: codemirror/codemirror5#5484
Vue.js version and component version
VueJs: 2.5.22
vue-codemirror: 4.0.6
Reproduction Link
As far as I can tell, this is a webpack related issue, so it would probably work fine on jsbin or other non-webpack environments.
Steps to reproduce
Create a new project using Vue cli v3 - i.e. using webpack v4. Add vue-codemirror.
What is Expected?
The codemirror instance should load its javascript & theme files, tokenize the input and apply highlighting.
What is actually happening?
It doesn't tokenize input and therefore doesn't apply syntax highlighting.
The fix
The fix from here appears to work. If you change this:
to this:
in both
codemirror.vue
&index.js
, that seems to fix things. I'm not sure if this is the "correct" way to fix this, so I've just made the change locally for now.If you modify
codemirror.vue
and/orindex.js
then you will need to pull these into your project - i.e. don't use the upstream npm package (from your node_modules) anymore, use your locally modified version.So, copy the those two files out of your
node_modules/vue-codemirror/
folder, into a folder in your project, saysrc/components/vue-codemirror/
, modify them, then change your import line from this:to this:
The text was updated successfully, but these errors were encountered: