Skip to content

Commit

Permalink
squash: use refactored upstream process_npm_assets script
Browse files Browse the repository at this point in the history
  • Loading branch information
kdmccormick committed Jan 10, 2023
1 parent 4df47d4 commit e8fc7e5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 51 deletions.
13 changes: 13 additions & 0 deletions tutor/templates/apps/openedx/settings/partials/common_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,5 +215,18 @@
"user": None,
}

# Upstream expects node_modules to be within edx-platform, but we put
# node_modules under /openedx/node_modules, so we must adjust any settings
# that hold a node_modules path.
NODE_MODULES_ROOT = "/openedx/node_modules/@edx"
STATICFILES_DIRS = [
*[
staticfiles_dir for staticfiles_dir in STATICFILES_DIRS
if "node_modules/@edx" not in staticfiles_dir
],
NODE_MODULES_ROOT,
]
PIPELINE["UGLIFYJS_BINARY"] = "/openedx/node_modules/.bin/uglifyjs"

{{ patch("openedx-common-settings") }}
######## End of settings common to LMS and CMS
52 changes: 1 addition & 51 deletions tutor/templates/build/openedx/bin/openedx-assets
Original file line number Diff line number Diff line change
Expand Up @@ -141,58 +141,8 @@ def run_xmodule(_args):
def run_npm(_args):
"""
Post-process npm assets.
Reimplementation of edx-platform's pavelib/assets.py:process_npm_assets()
"""

print(f"{sys.argv[0]}: Post-processing npm assets.")
print(f"{sys.argv[0]}: {NODE_MODULES_PATH=}")

# Create JS and CSS vendor directories.
sh(
"mkdir",
"-p",
"common/static/common/js/vendor",
"common/static/common/css/vendor",
)

# Copy studio-frontend CSS and JS into vendor directory.
copy_css = f"""\
find {NODE_MODULES_PATH}/@edx/studio-frontend/dist \
-type f \( -name \*.css -o -name \*.css.map \) | \
xargs cp --target-directory=common/static/common/css/vendor\
"""
copy_js = f"""\
find {NODE_MODULES_PATH}/@edx/studio-frontend/dist \
-type f \! -name \*.css \! -name \*.css.map | \
xargs cp --target-directory=common/static/common/js/vendor\
"""
sh("sh", "-c", copy_css)
sh("sh", "-c", copy_js)

# Copy certain node_modules into vendor directory.
sh(
"cp",
"-f",
"--target-directory=common/static/common/js/vendor",
f"{NODE_MODULES_PATH}/backbone.paginator/lib/backbone.paginator.js",
f"{NODE_MODULES_PATH}/backbone/backbone.js",
f"{NODE_MODULES_PATH}/bootstrap/dist/js/bootstrap.bundle.js",
f"{NODE_MODULES_PATH}/hls.js/dist/hls.js",
f"{NODE_MODULES_PATH}/jquery-migrate/dist/jquery-migrate.js",
f"{NODE_MODULES_PATH}/jquery.scrollto/jquery.scrollTo.js",
f"{NODE_MODULES_PATH}/jquery/dist/jquery.js",
f"{NODE_MODULES_PATH}/moment-timezone/builds/moment-timezone-with-data.js",
f"{NODE_MODULES_PATH}/moment/min/moment-with-locales.js",
f"{NODE_MODULES_PATH}/picturefill/dist/picturefill.js",
f"{NODE_MODULES_PATH}/requirejs/require.js",
f"{NODE_MODULES_PATH}/underscore.string/dist/underscore.string.js",
f"{NODE_MODULES_PATH}/underscore/underscore.js",
f"{NODE_MODULES_PATH}/which-country/index.js",
f"{NODE_MODULES_PATH}/sinon/pkg/sinon.js",
f"{NODE_MODULES_PATH}/squirejs/src/Squire.js",
)

sh("/bin/sh", "scripts/process-npm-assets.sh", "--node-modules", "/openedx/node_modules")

def run_webpack(args):
print(f"{sys.argv[0]}: Executing webpack")
Expand Down
13 changes: 13 additions & 0 deletions tutor/templates/build/openedx/settings/partials/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,17 @@
"default": {},
}

# Upstream expects node_modules to be within edx-platform, but we put
# node_modules under /openedx/node_modules, so we must adjust any settings
# that hold a node_modules path.
NODE_MODULES_ROOT = "/openedx/node_modules/@edx"
STATICFILES_DIRS = [
*[
staticfiles_dir for staticfiles_dir in STATICFILES_DIRS
if "node_modules/@edx" not in staticfiles_dir
],
NODE_MODULES_ROOT,
]
PIPELINE["UGLIFYJS_BINARY"] = "/openedx/node_modules/.bin/uglifyjs"

{{ patch("openedx-common-assets-settings") }}

0 comments on commit e8fc7e5

Please sign in to comment.