I'm currently trying to add Jquery to my vue-cli
project. I am aware of the missbehaviour it can produce, but anyway; Since there is no build/webpack.base.conf.js
anymore I tried editing vue.config.js
by adding:
module.exports {
...
chainWebpack: config => {
config.plugin('define').tap(definitions => {
definitions[0] = Object.assign(definitions[0], {
$: 'jquery',
jquery: 'jquery',
'window.jQuery': 'jquery',
jQuery: 'jquery',
_: 'lodash'
})
return definitions
})
}
...
}
or
const webpack = require('webpack')
module.exports {
...
plugins: [
new webpack.ProvidePlugin({
$: 'jquery',
jquery: 'jquery',
'window.jQuery': 'jquery',
jQuery: 'jquery'
})
]
...
}
Both options don't seem to work. With #1 nothing seems to happen, with #2 I get the compile error; "plugins" is not allowed or 'ProvidePlugin' is unresolved and when I try to import jQuery directly in main.js and define the $ operator, jquery stays undefinded when I try to use it.
Big thank you in advance!