Electron-vue: Cannot find jQuery when import bootstrap

Created on 24 Apr 2017  路  2Comments  路  Source: SimulatedGREG/electron-vue

Found an issue or bug? Tell me all about!

Describe the issue / bug.

#cannot find jQuery, after i set nodeIntegration: false, then report cannot find require function

How can I reproduce this problem?

#import jquery and bootstrap in main.js

If visual, provide a screenshot.

#

Tell me about your development environment.

If you are looking to suggest an enhancement or feature, then feel free to remove everything above.

question

Most helpful comment

Okay so if you want to use regular jquery and bootstrap, here's what needs to be done...

Add ProvidePlugin in .electron-vue/webpack.renderer.config.js around line 90

new webpack.ProvidePlugin({
  $: 'jquery',
  jQuery: 'jquery'
})

and in main.js...

window.jQuery = window.$ = require('jquery/dist/jquery.min')
import 'bootstrap/dist/js/bootstrap.min'
import 'bootstrap/dist/css/bootstrap.min.css'

Now I highly discourage using jQuery and Vue in the same environment because you are now using two frameworks for the same app. This not only bloats your app size, but it can also very easily lead to anti-patterns between Vue and jQuery. As an alternative you can look into something like vue-strap which takes bootstrap's JS functionalities and converts them to Vue instead of jQuery. This alternative yields better control over your data in the long run.

All 2 comments

Okay so if you want to use regular jquery and bootstrap, here's what needs to be done...

Add ProvidePlugin in .electron-vue/webpack.renderer.config.js around line 90

new webpack.ProvidePlugin({
  $: 'jquery',
  jQuery: 'jquery'
})

and in main.js...

window.jQuery = window.$ = require('jquery/dist/jquery.min')
import 'bootstrap/dist/js/bootstrap.min'
import 'bootstrap/dist/css/bootstrap.min.css'

Now I highly discourage using jQuery and Vue in the same environment because you are now using two frameworks for the same app. This not only bloats your app size, but it can also very easily lead to anti-patterns between Vue and jQuery. As an alternative you can look into something like vue-strap which takes bootstrap's JS functionalities and converts them to Vue instead of jQuery. This alternative yields better control over your data in the long run.

Even though, this 'post' is closed, I wanted to ask what alternative to jquery I can use, and if any of you can share a possible suggestion. I'll hard code all components, but I really want a lib for dom manipulation. By the way, I'm not asking for something I can google, but what lib have you used in that way (dom manipulation) with electron-vue. TY!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pansila picture pansila  路  3Comments

mvalim picture mvalim  路  4Comments

kinoli picture kinoli  路  3Comments

rodrigomata picture rodrigomata  路  3Comments

simonwjackson picture simonwjackson  路  3Comments