{"id":16299561,"url":"https://github.com/dcwatson/dpack","last_synced_at":"2025-04-09T21:28:50.815Z","repository":{"id":53838519,"uuid":"270644339","full_name":"dcwatson/dpack","owner":"dcwatson","description":"A static asset packager for Django.","archived":false,"fork":false,"pushed_at":"2023-12-16T00:36:39.000Z","size":31,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-20T14:08:54.001Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dcwatson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-08T11:34:37.000Z","updated_at":"2022-06-21T21:17:32.000Z","dependencies_parsed_at":"2024-11-05T20:37:21.011Z","dependency_job_id":"5d1ac56d-aaf1-469c-9ec4-06e4d4b85b4f","html_url":"https://github.com/dcwatson/dpack","commit_stats":{"total_commits":10,"total_committers":1,"mean_commits":10.0,"dds":0.0,"last_synced_commit":"53ce00695a95f5af893b425b3e898f4d136d0f1a"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcwatson%2Fdpack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcwatson%2Fdpack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcwatson%2Fdpack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcwatson%2Fdpack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dcwatson","download_url":"https://codeload.github.com/dcwatson/dpack/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248114224,"owners_count":21049997,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T20:48:31.452Z","updated_at":"2025-04-09T21:28:50.797Z","avatar_url":"https://github.com/dcwatson.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DPack\n\nDPack is a static asset packager, written primarily for Django applications.\n\n## Installation\n\n`pip install dpack`\n\nDPack has a number of optional processors for things like minification and compilation:\n\n* `pip install dpack[cssmin]`\n* `pip install dpack[jsmin]`\n* `pip install dpack[sass]`\n\nOr get everything with `pip install dpack[all]`.\n\n## Configuration\n\nDPack can be configured either via a `dpack.yaml` file, or via a `DPACK` setting if using Django. The following options\nare available:\n\n* `assets` - a dictionary whose keys are paths of files to be created (relative to `output`), and whose values are\n  lists of files to process and concatenate into said file. Each input file in the list may be prefixed by one or more\n  processors by specifying the processor name followed by a colon. For instance, `cssmin:sass:somefile.scss` tells\n  DPack to first compile `somefile.scss` (found by searching in `search` directories) using SASS, then minify it\n  using the `cssmin` processor.\n* `defaults` - a dictionary whose keys are file extensions (without the `.`), and whose values are lists of\n  processors to use by default for input files of that type.\n* `output` - the path to store packed assets under. If not specified, this will be a temporary directory created using\n  `tempfile.mkdtemp(prefix=\"dpack-\")`.\n* `prefix` - the URL prefix compiled assets will ultimately be served from, used when rewriting `url` and `@import`\n  declarations in CSS files via the `rewrite` processor. If using `DPackFinder`, this defaults to `STATIC_URL`.\n* `register` - a dictionary whose keys are processor names you wish to register (or override), and whose values are\n  dotted-path strings that resolve to a callable. See processors below.\n* `search` - a list of directories to search for input files in. If using `DPackFinder`, input files will be searches\n  by using any `STATICFILES_FINDERS` that are not `DPackFinder` itself.\n\n### Example `dpack.yaml`\n\n```yaml\nassets:\n  compiled/site.css:\n    - app1/first.css\n    - app2/second.css\n    - cssmin:sass:app3/third.scss\n  compiled/site.js:\n    - app1/first.js\n    - app2/second.js\ndefaults:\n  css:\n    - rewrite\n    - cssmin\n  js:\n    - jsmin\noutput: ./build\nprefix: /static/\nregister:\n  custom: myapp.processors.custom\nsearch:\n  - ./app1/static\n  - ./app2/static\n```\n\n### Example `DPACK` Setting\n\n```python\nDPACK = {\n    \"assets\": {\n        \"compiled/site.css\": [\n            \"app1/first.css\",\n            \"app2/second.css\",\n            \"cssmin:sass:app3/third.scss\",\n        ],\n        \"compiled/site.js\": [\n            \"app1/first.js\",\n            \"app2/second.js\",\n        ],\n    },\n    \"defaults\": {\n        \"css\": [\"rewrite\", \"cssmin\"],\n        \"js\": [\"jsmin\"]\n    },\n    \"output\": \"./build\",\n    \"register\": {\n        \"custom\": \"myapp.processors.custom\"\n    },\n}\n```\n\n## Using DPackFinder With Django\n\nSimply add `dpack.finders.DPackFinder` to your `STATICFILES_FINDERS` setting, and DPack will search for inputs using\nDjango's `staticfiles` app, output compiled assets when `collectstatic` is called, and generate assets on-the-fly when\nserving with `runserver` (`DEBUG=True`) or via the `django.contrib.staticfiles.views.serve` view.\n\n```python\nSTATICFILES_FINDERS = (\n    \"django.contrib.staticfiles.finders.FileSystemFinder\",\n    \"django.contrib.staticfiles.finders.AppDirectoriesFinder\",\n    \"dpack.finders.DPackFinder\",\n)\n```\n\nIf you compile an asset to `compiled/css/site.css`, you can reference it as you would any other static asset, with\n`{% static \"compiled/css/site.css\" %}` in your templates. These assets are also then post-processed by your\n`STATICFILES_STORAGE`, so you can use things like [Whitenoise](http://whitenoise.evans.io)'s `CompressedManifestStaticFilesStorage` with no extra configuration.\n\n## Command Line Interface\n\nDPack comes with a command-line utility, unsurprisingly named `dpack`. Run by itself, it will look for a `dpack.yaml`\nconfig file and pack any assets it finds according to the config. You can specify a config file (`-c`) or Django\nsettings module (`-s`), and dump out the loaded config using `dpack -y`. Run `dpack -h` for a full list of options.\n\n## Processors\n\nProcessors are simply Python callables that take three arguments: `text` (the processed text so far), `input` (the\n`dpack.base.Input` object containing things like relative `name` and absolute `path`), and `packer` (an instance of\n`dpack.DPack` containing things like `prefix`). For example, the `cssmin` processor is implemented as:\n\n```python\ndef process(text, input, packer):\n    return rcssmin.cssmin(text)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdcwatson%2Fdpack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdcwatson%2Fdpack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdcwatson%2Fdpack/lists"}