DynamoMTL / shopify-pipeline

Shopify Pipeline - A modern pipeline for Shopify theme development
MIT License
86 stars 16 forks source link

Vendors pass-through not working for script tags? #98

Closed lastobelus closed 6 years ago

lastobelus commented 6 years ago

The assets/vendors + single-quote passthru mechanism, is not working for me with script tags:

If I use:

<script src='{{ 'match-media.min.js' | asset_url }}'></script>

I get:

Error: Cannot find module '/XXX/shopify-pipeline-test/src/layout/match-media.min.js'

And if I try to add in the relative path:

  <script src='{{ '../assets/vendor/match-media.min.js' | asset_url }}'></script>

Webpack tries to compile it and I get:

ReferenceError: window is not defined (or other error caused by trying to compile an oldskool js file with transpiler)

Have I misunderstood something about how to set this up?

Also, I think passthru should also work with {{ 'some_path' | asset_url | script_tag}}.

nddery commented 6 years ago

What happens if you use double quotes inside of the src attribute ? Like so:

<script src='{{ "match-media.min.js" | asset_url }}'></script>

The reason to use single quote around the src attribute is so that we can use double quotes inside the liquid expression.

lastobelus commented 6 years ago

Duh! yes, it works and I feel chagrined.