forked from overhangio/tutor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: don't unneccessarily rebuild dev assets
TODO: * is the pre-assets patch in the right place? * changelog entry * more details in commit message * test with 'tutor local'
- Loading branch information
1 parent
044eede
commit 3acb49f
Showing
3 changed files
with
221 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/bin/sh | ||
# | ||
# Frontend assets need to be generated in the edx-platform repository. | ||
# However, when a developer bind-mounts edx-platform, it completely overwrites the repo. | ||
|
||
# So, the Dockerfile instead generates the assets *outside* of edx-platform | ||
# where they will not be overwritten by a bind-mount. This script ensures that edx-platform | ||
# contains symlinks to those assets. This script is run both in the Dockerfile and in lms's | ||
# init job; that way, the symlinks exist regardless of whether edx-platform is bind-mounted. | ||
# | ||
# USAGE: | ||
# | ||
# ln-assets ASSETS_DIR EDX_PLATFORM_DIR | ||
# | ||
# where EDX_PLATFORM_DIR is to contain symlinks to assets in ASSETS_DIR. | ||
# ASSETS_DIR must be an absolute directory. | ||
# | ||
# ASSET DIRECTORY | PURPOSE | ||
# ----------------------------------+--------------------------------------------- | ||
# node_modules | npm packages | ||
# common/static/common/js/vendor | npm JS copies, for use by RequireJS | ||
# common/static/common/css/vendor | npm CSS copies, for use by RequireJS | ||
# common/static/bundles | JS bundles, generated by Webpack | ||
# cms/static/css | Studio CSS, compiled from Sass | ||
# lms/static/css | LMS CSS, compiled from Sass | ||
# lms/static/certificates/css | Certificate CSS, compiled from Sass | ||
|
||
set -eu | ||
|
||
assets="$1" | ||
edx_platform="$2" | ||
|
||
echo "Create static asset symlinks in $edx_platform towards $assets..." | ||
set -x | ||
|
||
cd "$edx_platform" || ( echo "could not cd to $edx_platform" ; exit 1 ) | ||
|
||
for dir in \ | ||
node_modules \ | ||
common/static/common/js/vendor \ | ||
common/static/common/css/vendor \ | ||
common/static/bundles \ | ||
cms/static/css \ | ||
lms/static/css \ | ||
lms/static/certificates/css ; do | ||
|
||
# If there isn't a symlink or there's one to the wrong place, then fix it | ||
if test "$(readlink -f $dir)" != "$assets/$dir" ; then | ||
|
||
# If there's an existing symlink (to the wrong place), delete it | ||
if [ -L $dir ] ; then | ||
rm $dir | ||
|
||
# If there's a file or a dir already, back it up | ||
elif [ -d $dir ] || [ -f $dir ] ; then | ||
mv -f $dir $dir.bak | ||
fi | ||
|
||
# Ensure the symlink's parent dir exists | ||
mkdir -p "$(dirname "$dir")" | ||
|
||
# Create the correct symlink | ||
ln -s "$assets/$dir" $dir | ||
fi | ||
done | ||
|
||
set -x | ||
echo "Done symlinking static assets." |
Oops, something went wrong.