Back to Notes

How to import jQuery into VueJS

Time: less than one minute

Currently working on a Vue.js project and had a bit of a snag when trying to import jQuery into my project.

The solution I found is from Maketips and is for projects created via the vue cli webpack.

yarn add jquery -D

Instead of opening build/webpack.base.conf.js, as the post suggests, open config/webpack.dev.conf.js and after new FriendlyErrorsPlugin() add:

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

zimba is a full-stack developer specialising in ruby on rails and javascript. a lover of linux, storytelling and meditation. discover more of her journey here

Read Next

Heroku: How to Deploy a Static VueJS app