Skip to main content

Configuration

django-rspack loads configuration from three sources, in order of precedence:

  1. Django settingsRSPACK dict in settings.py
  2. YAML config fileconfig/shakapacker.yml (same format as Shakapacker for Rails)
  3. Bundled defaults — Sensible defaults shipped with the package

Django settings

# settings.py
RSPACK = {
"source_path": "app/javascript",
"source_entry_path": "packs",
"public_root_path": "public",
"public_output_path": "packs",
"cache_manifest": False,
"compile": True,
"dev_server": {
"host": "localhost",
"port": 3035,
"server": "http",
"hmr": False,
},
}

YAML config file

The YAML file uses environment-specific sections:

# config/shakapacker.yml
default: &default
source_path: app/javascript
source_entry_path: packs
public_root_path: public
public_output_path: packs

development:
<<: *default
compile: true
dev_server:
host: localhost
port: 3035

production:
<<: *default
compile: false
cache_manifest: true

All configuration options

Paths

OptionDefaultDescription
source_pathapp/javascriptRoot directory for JavaScript/CSS source files
source_entry_pathpacksSubdirectory containing entry points (relative to source_path)
public_root_pathpublicPublic root directory
public_output_pathpacksOutput directory for compiled assets (relative to public_root_path)
manifest_path<public_output_path>/manifest.jsonPath to the manifest file
cache_pathtmp/rspackDirectory for build cache
config_pathconfig/shakapacker.ymlPath to the YAML config file

Compilation

OptionDefault (dev)Default (prod)Description
compiletruefalseEnable auto-compilation when assets are requested
compile_outputtruetrueShow Rspack compilation output
cache_manifestfalsetrueCache manifest.json in memory
compiler_strategymtimedigestHow to check if assets are stale (mtime or digest)
useContentHashfalsetrueUse content hashes in output filenames
nested_entriestruetrueAllow entry points in subdirectories

Dev server

OptionDefaultDescription
dev_server.hostlocalhostDev server hostname
dev_server.port3035Dev server port
dev_server.serverhttpProtocol (http or https)
dev_server.hmrfalseEnable Hot Module Replacement
dev_server.inline_csstrueInline CSS via JavaScript (for HMR)
dev_server.compresstrueEnable gzip compression

Asset delivery

OptionDefaultDescription
asset_hostNoneCDN or asset host URL
integrity.enabledfalseEnable Subresource Integrity (SRI)
integrity.hash_functions["sha384"]SRI hash algorithms
integrity.cross_originanonymousCORS setting for SRI

Environment variables

VariableDescription
RSPACK_ENVOverride environment detection (development, production, test)
RSPACK_DEV_SERVER_HOSTOverride dev server host
RSPACK_DEV_SERVER_PORTOverride dev server port
RSPACK_DEV_SERVER_SERVEROverride dev server protocol
RSPACK_ASSET_HOSTOverride asset host URL

Environment detection

By default, django-rspack maps Django's DEBUG setting:

  • DEBUG = Truedevelopment environment
  • DEBUG = Falseproduction environment

Override with the RSPACK_ENV environment variable:

RSPACK_ENV=production python manage.py rspack_compile

Accessing configuration in code

from django_rspack.conf import get_config

config = get_config()
print(config.manifest_path)
print(config.dev_server_url)
print(config.compile)