IMHO it could be quite helpful to add an “eject” task to Sage that automatically creates a minimal theme ZIP as build artifact.
Note: node_modules/
is only required for building the theme - it is not needed and should not be needed by the theme during runtime. If there are any files that should be available for the theme, either add them using webpack (e.g. imported SASS, url(...)
) or copy them from node_modules/
into dist/
or - for some cases - resources/
.
For Sage 10 themes:
#!/bin/sh
echo 'Building theme.zip from Sage 10 theme.' && \
echo "Note: This script doesn't clean up the existing temporary folder (./theme-zip-contents). You have to do this your yourself." && \
echo '(1/4) Ensuring all theme composer dependencies are installed (theme runtime)...' && \
composer install -q && \
echo '(2/4) Ensuring folder for theme zip contents...' && \
mkdir -p ./theme-zip-contents && \
echo '(3/4) Copying relevant theme files into folder...' && \
cp -a ./style.css ./theme-zip-contents/ && \
cp -a ./functions.php ./theme-zip-contents/ && \
cp -a ./index.php ./theme-zip-contents/ && \
cp -a ./screenshot.png ./theme-zip-contents/ && \
cp -aR ./app ./theme-zip-contents/ && \
cp -aR ./config ./theme-zip-contents/ && \
cp -aR ./public ./theme-zip-contents/ && \
cp -aR ./vendor ./theme-zip-contents/ && \
cp -a ./bootstrap/app.php ./theme-zip-contents/ && \
echo '(4/4) Creating theme zip file...' && \
zip -r -q ./theme.zip ./theme-zip-contents/* && \
echo 'Done. You find the theme zip as `theme.zip` inside this directory.'
This script above creates (should create) a ZIP with the minimal set of files needed to use the plugin.
For Sage 9 themes:
#!/bin/sh
echo 'Building theme.zip from Sage 9 theme.' && \
echo "Note: This script doesn't clean up the existing temporary folder (./theme-zip-contents). You have to do this your yourself." && \
echo '(1/4) Ensuring all theme composer dependencies are installed (theme runtime)...' && \
composer install -q && \
echo '(2/4) Ensuring folder for theme zip contents...' && \
mkdir -p ./theme-zip-contents && \
echo '(3/4) Copying relevant theme files into folder...' && \
cp -aR ./app ./theme-zip-contents/ && \
cp -a ./composer.lock ./theme-zip-contents/ && \
cp -a ./composer.lock ./theme-zip-contents/ && \
cp -aR ./config ./theme-zip-contents/ && \
cp -aR ./dist ./theme-zip-contents/ && \
cp -aR ./resources ./theme-zip-contents/ && \
cp -aR ./vendor ./theme-zip-contents/ && \
echo '(4/4) Creating theme zip file...' && \
zip -r -q ./theme.zip ./theme-zip-contents/* && \
echo 'Done. You find the theme zip as `theme.zip` inside this directory.'