Asset Compilation#
The theme’s CSS and JavaScript are compiled from source files in
src/quantecon_book_theme/assets/ using webpack.
Quick Reference#
# Compile SCSS and JS
npm run build
# Install webpack and dependencies
npm install
Workflow#
Edit source files in
src/quantecon_book_theme/assets/SCSS files in
assets/styles/JavaScript files in
assets/scripts/
Compile with webpack:
$ npm run build
Output goes to
src/quantecon_book_theme/theme/quantecon_book_theme/static/.Preview by rebuilding the docs:
$ rm -rf docs/_build/html $ tox -e docs-update
Or use the live-reload server:
$ tox -e docs-live
:::{note}
You can also use tox -e compile which runs the
Sphinx Theme Builder, but
npm run build is faster for quick iterations.
:::
Build Dependencies#
Defined in package.json:
Package |
Purpose |
|---|---|
|
Module bundler |
|
SCSS compilation |
|
CSS processing |
|
CSS minification |
SCSS Architecture#
The entry point is assets/styles/index.scss. It uses @forward to include
all modules. See Architecture — SCSS Modules
for the full module list.
When adding a new SCSS module:
Create
_my-module.scssinassets/styles/Add
@forward "my-module";toindex.scssRun
npm run buildUpdate the test in
test_module_structure.py
JavaScript Architecture#
The entry point is assets/scripts/index.js. It imports all feature modules.
See Architecture — JavaScript Modules
for the full module list.
When adding a new JS module:
Create
my-feature.jsinassets/scripts/Export an
initMyFeaturefunctionImport and call it from
index.jsRun
npm run buildUpdate the test in
test_module_structure.py