Closed felixmosh closed 3 years ago
@felixmosh this is really cool 😎! Using webpack dev server is a great idea on how to solve this issue as we only need it during development mode. I have a couple questions testing this out.
The main one is when I run yarn start
I see everything build and watch correctly but if I make a change the browser does not refresh. If I refresh the browser manually I see an error in the console.
I'm not sure what's causing this to throw?
@felixmosh this is really cool 😎! Using webpack dev server is a great idea on how to solve this issue as we only need it during development mode. I have a couple questions testing this out.
The main one is when I run
yarn start
I see everything build and watch correctly but if I make a change the browser does not refresh. If I refresh the browser manually I see an error in the console. I'm not sure what's causing this to throw?
Aww, I’ve forgot... it uses a self signed ssl certificate, when I’ve tested it I’ve approved it once (open the local host link in a new tab, and approve it) The other method is to pass a valid certificate as mentioned here https://webpack.js.org/configuration/dev-server/#devserverhttps
Thank you @felixmosh I am sure this is local to my machine but I am having a hard time getting the self signed ssl certificate to work. When I try to open the local host link in a new tab I don't see any option to approve it in Chrome or Firefox. Looking the the link for the webpack CLI I was also unsuccessful.
Can you help me find an easy way to approve the SSL Cert so I can update the readme with easy instructions for users?
@felixmosh I think I solved the Cert issue but maybe not completely the browser loads the assets correctly but is not refreshing? Let me know if I am doing something wrong or need to set something up. Thanks!
Looks like it works, changes in .liquid
files just re-uploaded, since themekit watch runs in parallel, webpack doesn’t know when it finished, therefore the page reload is disabled (it refreshed the page before it was uploaded)
Try to change styles ;)
BTW, I'm thinking about a bizarre idea of a full HMR support for .liquid
files 😎.
The idea is to make a loader which will load all .liquid
files, which will wrap each .liquid
content with start & end html comments & execute the template file locally.
Then add a JS entry point which will register HMR changes for .liquid
files and apply the change at runtime by replacing blocks (which defined by html comments) with the local render.
Few things to handle:
schema
, section
) are not supported by liquidjs, found some initial implementation here: https://github.com/harttle/liquidjs-section-tags, probably will require several PR'sBut this seems like a big project :]
Thanks @felixmosh I see so we get HMR on CSS and JS but not yet liquid.
I am excited for your idea for a full version. There is a Liquid Loader that exists but I am not sure if it works like you would need.
This would be a pretty major project and having to reload the browser for changes is much easier than restarting the server. I'll get this feature merged in. That said if you're up for it a full HMR on this project would be really cool. Happy to jump in and help with whatever I can.
This was a massive update and thank you for the contribution! Really nice work you have done here 👏
This PR adds HMR support for
The idea is simple, in development mode we are using webpack's dev server in-order to serve static assets. Notes:
style-loader
which injects styles to the js bundle, therefore, in development mode there is no need for the liquid{{ 'bundle.*.css' | asset_url | stylesheet_tag }}
tags - it get's removed using the transform of.liquid
files.{{ 'bundle.*.js' | asset_url | script_tag }}
tags into script tags that points tolocalhost:9000
.themkit watch mode
which syncs shopify with changes - so if.liquid
file changes, it gets written to disk &themekit
upload it.development
&production
- in dev it ignores webpack's & js files..css
&.js
files as expected without any.liquid
modificationsHope it helps :]