uicrooks / shopify-theme-lab

Shopify theme development environment using Liquid, Vue and Tailwind CSS. Built on top of Shopify CLI 🧪
https://uicrooks.github.io/shopify-theme-lab-docs/
MIT License
727 stars 128 forks source link

Adding jQuery #130

Closed fowlercraig closed 2 years ago

fowlercraig commented 2 years ago

Operating system

macOS Big Sur

Node.js version

16

Shopify CLI version

2

Browsers

Chrome, Safari

Version

4 (Current)

Modifications

No response

Details

Can you explain the steps to adding jQuery?

I have a couple plugins that unfortunately required it -- I've tried a number of ways including using the ProvidePlugin in the webpack configuration, but keep getting the error "$ is undefined".

Notice

sergejcodes commented 2 years ago

Install the jquery npm package and instead of modifying the webpack config try adding the following code to the src/main.js file (somewhere at the top):

import $ from 'jquery'
window.jQuery = $
window.$ = $
fowlercraig commented 2 years ago

that worked, thanks!