Compiling Liquid Theme Resources
On this page
Directory Structure Overview
theme/
└── resources/
├── build/
│ ├── files-config.js
│ ├── helpers.js
│ ├── index.js
│ ├── scripts-config.js
│ └── styles-config.js
├── src/
│ ├── files/
│ ├── scripts/
│ └── styles/
├── script.liquid
├── style.liquid
├── package.json
└── package-lock.json
✅ Prerequisites
Ensure Node.js is installed on your machine.
Install Node (macOS Example):
brew update
brew install node
Verify installation:
node -v
npm -v
🔧 Step-by-Step Instructions
-
Navigate to the Resources Directory
cd theme/resources -
Install Dependencies
This installs everything from
package.json:npm install -
Run the Build Script
npm run build -
Expected Output
[esbuild theme scripts] building... [esbuild theme scripts] ...done [esbuild theme styles] building... [esbuild theme styles] ...done [esbuild theme files] building... [esbuild theme files] ...done
🛠 Additional Commands
| Command | Description |
|---|---|
| npm run build | Build scripts, styles, and files |
| npm run watch | Watch for changes and auto-recompile (with minify) |
| npm run clean | Remove dist/ and rebuild |
| npm run heroku-postbuild | Production build with minify and cleanup |
📌 Optional Tasks
🧹 Clean
After extended development, compiled output may become bloated. You can clean and regenerate only the latest files by running:
npm run clean
This removes the dist/ directory and runs a fresh build.
🚀 Production
To prepare a final production version for deployment:
- Clean the build:
npm run clean
- Run a minified production build:
npm run heroku-postbuild
This generates a fully packaged and minified resources folder suitable for use with the StoreConnect Theme Importer.
📝 Minor Changes
To make minor updates to only a few scripts, styles, or assets without a full theme re-import, you can overwrite the manifest to include only the changed files.
-
Run the watch script:
npm run watch -
Edit the desired files:
As you make changes to JavaScript, CSS, or static files in
resources/src/, esbuild will automatically compile and generate updated hashed files inresources/dist/. -
Deploy selective updates without full import:
- Open Salesforce.
- Navigate to the Themes tab.
- Open the Theme record you want to update.
- Navigate to the Theme Templates section.
-
Create or update the appropriate template for each modified file. Use these template key formats:
- Scripts:
resources/dist/scripts/[dir]/[filename].[hash].js - CSS:
resources/dist/css/[dir]/[filename].[hash].css - Files:
resources/dist/files/[dir]/[filename].[hash].[ext]
- Scripts:
-
Create or modify a template with the key:
resources/dist/manifest.jsonThis maps updated files to their unhashed equivalents and augments the existing manifest without overwriting the full bundle. Example format:
{ "dist/scripts/bundles.js": "dist/scripts/bundles.KCS3ODL5.js", "dist/css/utils/dropdown.css": "dist/css/utils/dropdown.GRARK238.css", "dist/files/logo.png": "dist/files/logo.IJQZ82PO.png" }
📌 Notes on Hashing
The [hash] in filenames is used for browser caching. When a file changes, its hash will change. To ensure updated files are loaded, make sure:
- The new
[hash]is used in both the file name and themanifest.jsontemplate. - You’re using esbuild in watch mode or running a fresh build after edits.
🧩 Usage in the Theme
Within your Liquid templates, you should reference the unhashed resource names. The Theme engine will resolve these using manifest.json.
{% require 'scripts/bundles.js' %}
{% require 'css/utils/dropdown.css' %}
{% require 'files/logo.png' %}
✅ Summary
- Navigate:
cd theme/resources - Install:
npm install - Build:
npm run build - Watch:
npm run watch - Clean:
npm run clean - Prod Build:
npm run heroku-postbuild