Section's code rolls back to what it was before on Deploy

Solved
Highlighted
Tourist
6 2 0

Hi all,

 

I'm having a weird issue. For some reason whenever I deploy, all my changes under inside the section file gets rolled back to the previous code... Can't really understand what's happening...

 

This:

<section class="content-area" data-section-id="{{ section.id }}" data-section-type="slideshow-section">
	<main id="main" class="site-main site-half-margins">
		{%- if section.blocks.size > 0 -%}
			{%- for block in section.blocks -%}
				<div class="stockist site-half-margins" {{ block.shopify_attributes }}>
					<p class="stockist--name balance-text">
						{% if block.settings.stockist_isOnline %}
								<a href="{{ block.settings.stockist_address | escape }}" target="_blank">
						{% else %}
								<span>
						{% endif %}

						{{ block.settings.store_name | escape }}

						{% if block.settings.stockist_isOnline %}
								</a>
						{% else %}
								</span>
						{% endif %}
					</p>

					{% if block.settings.stockist_isOnline == false %}
						<p class="stockist--address">{{ block.settings.stockist_address | escape }}</p>
					{% endif %}
				</div>
			{%- endfor -%}
		{%- endif -%}
	</main>
</section>

{% schema %}
{
	"name":"Stockists",
	"class":"stockists p__stockists",
	"max_blocks":6,
	"settings":[],
	"blocks":[
		{
			"type":"stockist",
			"name":"Stockist",
			"settings":[
				{
					"type":"text",
					"id":"store_name",
					"label":"Store Name",
					"default":"Store Name"
				},
				{
					"type":"text",
					"id":"stockist_address",
					"label":"Store URL or physical Address",
					"default":"Store Address"
				},
				{
					"type":"checkbox",
					"id":"stockist_isOnline",
					"label":"This is an online business",
					"default":false
				}
			]
		}
	],
	"presets":[
		{
			"name":"Stockists",
			"category":"Store information",
			"blocks":[
				{
					"type":"stockist"
				},
				{
					"type":"stockist"
				}
			]
		}
	]
}
{% endschema %}

Gets changed to this:

<div data-section-id="{{ section.id }}" data-section-type="slideshow-section">
  {%- if section.blocks.size > 0 -%}
    {%- for block in section.blocks -%}
        <div class="stockist site-half-margins" {{ block.shopify_attributes }}>
            <p class="stockist--name balance-text">
                {% if block.settings.stockist_isOnline %}
                    <a href="{{ block.settings.stockist_address | escape }}" target="_blank">
                {% else %}
                    <span>
                {% endif %}

                {{ block.settings.store_name | escape }}

                {% if block.settings.stockist_isOnline %}
                    </a>
                {% else %}
                    </span>
                {% endif %}
            </p>

            {% if block.settings.stockist_isOnline == false %}
                <p class="stockist--address">{{ block.settings.stockist_address | escape }}</p>
            {% endif %}
        </div>
    {%- endfor -%}
  {%- endif -%}
</div>

{% schema %}
{
    "name":"Stockists",
    "class":"index-section index-section--flush index-section--stockists",
    "max_blocks":6,
    "settings":[],
    "blocks":[
        {
            "type":"stockist",
            "name":"Stockist",
            "settings":[
                {
                    "type":"text",
                    "id":"store_name",
                    "label":"Store Name",
                    "default":"Store Name"
                },
                {
                    "type":"text",
                    "id":"stockist_address",
                    "label":"Store URL or physical Address",
                    "default":"Store Address"
                },
                {
                    "type":"checkbox",
                    "id":"stockist_isOnline",
                    "label":"This is an online business",
                    "default":false
                }
            ]
        }
    ],
    "presets":[
        {
            "name":"Stockists",
            "category":"Store information",
            "blocks":[
                {
                    "type":"stockist"
                },
                {
                    "type":"stockist"
                }
            ]
        }
    ]
}
{% endschema %}

Is there any reason? Why doesn't it give me an error or something and it just changes all my actual code?? 

 

Thanks a lot!

Alex

 

0 Likes
Tourist
6 2 0

Ok, probably not an issue that a lot of people might have, but here is the solution.

 

It turns out that the file, somehow, even though it was saving on Sublime Text, it wasn't triggering the "yarn watch" related functionalities. I understood that by trying to make modifications in other sections and seeing if it saved/deployed, which it did. Second I tried to see if I would see the typical "Compiling..." message that occurs when you the server is watching your files and you hit save, and the only one that wasn't doing that was this one file. Closed that tab on Sublime Text and open again, hit save and this time I saw the "Compiling..." message.

 

Don't know exactly what was the cause and what really triggers a full roll back and overriding of the section file to the previous code... maybe not even an issue with slate but Sublime Text? Anyways, that's it.

0 Likes

Success.

Tourist
6 2 0

Ok... the actual solution is this one, and is one that many people might fall under without noticing.

 

When on Sublime Text or other editors we use the Go To shortcut to quickly open a file within our project it usually will include all folders within. These can be the intended or in this case can be folders like "dist" where the compiled files are sent to.

 

What was happening was that this project always opened dist files (which have the same name) because Shopify actually uses this folder to send ALL code to the server, thus duplicating every single file to it, instead of the usual style.min.css or app.min.js, etc.

 

A workaround is to actually create a project file specific to your IDE that excludes it. In this case my project-name.sublime-project file now shows:

 

{
    "folders": [
        {
            "path": ".",
            "binary_file_patterns": [
                "dist/",
                "node_modules/"
            ]
        }
    ],
    "settings": {
        "translate_tabs_to_spaces": false,
        "tab_size": 4
    }
}

Hope it helps.

0 Likes