What is the correct way to import jQuery and fancybox into a Vue component so it gets bundled correctly. Does it need to be at the highest App level, or just at the component using fancybox?
Most of the solutions I've seen on here use ProvidPlugin and webpack. This project does not use webpack.
I run into 'no unused' or 'not defined' problems with this:
import $ from 'jQuery'
import fancybox from 'fancybox';
My implementation is the inline vanilla varity, i.e. just adding "data-fancybox" to a link.
I have no problem if I just call jQuery and fancybox from a CDN in the index.html, but I want to learn the right way so it's bundled in.
package.json
{
"name": "inv-dash",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"test:unit": "vue-cli-service test:unit",
"test:e2e": "vue-cli-service test:e2e",
"lint": "vue-cli-service lint"
},
"dependencies": {
"airtable": "^0.7.1",
"axios": "^0.19.0",
"core-js": "^3.3.2",
"fslightbox-vue": "^1.0.2",
"imagesloaded": "^4.1.4",
"inuitcss": "^6.0.0",
"masonry-layout": "^4.2.2",
"material-icons": "^0.3.1",
"to-title-case": "^1.0.0",
"vue": "^2.6.10",
"vue-agile": "^1.0.11",
"vue-carousel": "^0.18.0",
"vue-images-loaded": "^1.1.2",
"vue-js-toggle-button": "^1.3.3",
"vue-lazyload": "^1.3.3",
"vue-masonry": "^0.11.8",
"vue-masonry-css": "^1.0.3",
"vue-nl2br": "^0.1.2",
"vue-router": "^3.1.3",
"vue-select": "^3.2.0",
"vue-toasted": "^1.1.27",
"vue-truncate-collapsed": "^2.1.0",
"vueisotope": "^3.1.2",
"vuex": "^3.1.1"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^4.0.0",
"@vue/cli-plugin-e2e-cypress": "^4.0.0",
"@vue/cli-plugin-eslint": "^4.0.0",
"@vue/cli-plugin-router": "^4.0.0",
"@vue/cli-plugin-unit-jest": "^4.0.0",
"@vue/cli-plugin-vuex": "^4.0.0",
"@vue/cli-service": "^4.0.0",
"@vue/eslint-config-prettier": "^5.0.0",
"@vue/test-utils": "1.0.0-beta.29",
"babel-eslint": "^10.0.3",
"eslint": "^5.16.0",
"eslint-plugin-prettier": "^3.1.1",
"eslint-plugin-vue": "^5.0.0",
"lint-staged": "^9.4.2",
"node-sass": "^4.12.0",
"prettier": "^1.18.2",
"sass-loader": "^8.0.0",
"vue-template-compiler": "^2.6.10"
},
"gitHooks": {
"pre-commit": "lint-staged"
},
"lint-staged": {
"*.{js,vue}": [
"prettier --write",
"git add"
]
}
}