This repository has been archived by the owner on Jul 19, 2021. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TL;DR: Slate performs a number of magic transformations to the theme’s
src/assets/
directory which ultimately result in developer confusion. This PR simplifies how Slate manages and transforms assets to achieve an easier to understand and reliable developer experience.Problems
The
/assets
directoryIn its current state, Slate does a lot of magic to a theme’s
assets/
directory, including:assets/svgs
tosnippets/
so SVGs can be inlined in a theme using{% include %}
assets/scripts
into layout and template specific bundles.src/assets/static
todist/assets
src/assets/images
todist/assets
src/assets
if they are referenced using theasset_url
somewhere in a Liquid file ({{ '../assets/my-image.jpg' | asset_url }}
), or imported into one of the bundles (import '../styles/theme.scss'
)Related Issues
src/assets
folder works and how it’s used in a themeReferencing assets via relative paths
Slate also attempts to serve assets from a local asset server by using relative paths: ``` {{ '../assets/my-image.jpg' | asset_url }} ```And then swaps the path for one that references the dev machine's local IP when in development, or one that will result in a valid
cdn.shopify.com
path for production build. This works great when the tag is structured exactly like the above, but breaks for examples like the following:Related issues
Solution
This PR includes the following changes:
src/assets
are statically copied todist/assets
.Folders insideContents of folders are copied. We need to flush out what happens when there is a naming conflict. Usingsrc/assets
are not copied.flatten
option from copy-webpack-plugin{{ '../assets/my-image.jpg | asset_url }}
is now{{ 'my-image.jpg' | asset_url }}
.snippets/style-tags.liquid
andsnippets/script-tags.liquid
are fetched from your local server in development, all other assets referenced in your theme are fetched from Shopify CDN. This makes sure we can still take advantage of Hot Module Replacement and quick change previewing while modifying styles and scripts.src/assets/svgs
should be renamed from `src/assets/scripts
have moved tosrc/scripts
src/assets/styles
have moved tosrc/styles
TODO