Asset packager for Django.
Project description
DPack
DPack is a static asset packager, written primarily for Django applications.
Installation
pip install dpack
DPack has a number of optional processors for things like minification and compilation:
pip install dpack[cssmin]
pip install dpack[jsmin]
pip install dpack[sass]
Or get everything with pip install dpack[all]
.
Configuration
DPack can be configured either via a dpack.yaml
file, or via a DPACK
setting if using Django. The following options
are available:
assets
- a dictionary whose keys are paths of files to be created (relative tooutput
), and whose values are lists of files to process and concatenate into said file. Each input file in the list may be prefixed by one or more processors by specifying the processor name followed by a colon. For instance,cssmin:sass:somefile.scss
tells DPack to first compilesomefile.scss
(found by searching insearch
directories) using SASS, then minify it using thecssmin
processor.defaults
- a dictionary whose keys are file extensions (without the.
), and whose values are lists of processors to use by default for input files of that type.output
- the path to store packed assets under. If not specified, this will be a temporary directory created usingtempfile
.prefix
- the URL prefix compiled assets will ultimately be served from, used when rewritingurl
and@import
declarations in CSS files via therewrite
processor. If using Django, this defaults toSTATIC_URL
.register
- a dictionary whose keys are processor names you wish to register (or override), and whose values are dotted-path strings that resolve to a callable. See processors below.search
- a list of directories to search for input files in. If using Django, input files will be searches by using anySTATICFILES_FINDERS
that are not DPack itself.
dpack.yaml
assets:
compiled/site.css:
- app1/first.css
- app2/second.css
- cssmin:sass:app3/third.scss
compiled/site.js:
- app1/first.js
- app2/second.js
defaults:
css:
- rewrite
- cssmin
js:
- jsmin
output: ./build
prefix: /static/
register:
custom: myapp.processors.custom
search:
- ./app1/static
- ./app2/static
DPACK
Setting
DPACK = {
"assets": {
"compiled/site.css": [
"app1/first.css",
"app2/second.css",
"cssmin:sass:app3/third.scss",
],
"compiled/site.js": [
"app1/first.js",
"app2/second.js",
],
},
"defaults": {
"css": ["rewrite", "cssmin"],
"js": ["jsmin"]
},
"output": "./build",
"register": {
"custom": "myapp.processors.custom"
},
}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
dpack-0.1.0-py3-none-any.whl
(8.2 kB
view hashes)