{"id":19056335,"url":"https://github.com/kottenator/django-compressor-toolkit","last_synced_at":"2025-08-08T02:06:56.003Z","repository":{"id":57419465,"uuid":"46137454","full_name":"kottenator/django-compressor-toolkit","owner":"kottenator","description":"Simply enable SCSS and ES6 in your Django project","archived":false,"fork":false,"pushed_at":"2018-05-22T14:32:45.000Z","size":77,"stargazers_count":76,"open_issues_count":8,"forks_count":12,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-17T09:55:50.563Z","etag":null,"topics":["autoprefixer","django-compressor","es6","scss"],"latest_commit_sha":null,"homepage":"","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/kottenator.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.mit","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-11-13T17:39:20.000Z","updated_at":"2024-10-20T18:12:39.000Z","dependencies_parsed_at":"2022-09-08T06:11:51.204Z","dependency_job_id":null,"html_url":"https://github.com/kottenator/django-compressor-toolkit","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/kottenator/django-compressor-toolkit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kottenator%2Fdjango-compressor-toolkit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kottenator%2Fdjango-compressor-toolkit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kottenator%2Fdjango-compressor-toolkit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kottenator%2Fdjango-compressor-toolkit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kottenator","download_url":"https://codeload.github.com/kottenator/django-compressor-toolkit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kottenator%2Fdjango-compressor-toolkit/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267617643,"owners_count":24116208,"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","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["autoprefixer","django-compressor","es6","scss"],"created_at":"2024-11-08T23:49:07.112Z","updated_at":"2025-07-29T02:06:08.035Z","avatar_url":"https://github.com/kottenator.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# django-compressor-toolkit\n\n[![Build Status](https://travis-ci.org/kottenator/django-compressor-toolkit.svg?branch=master)](https://travis-ci.org/kottenator/django-compressor-toolkit)\n\nSet of add-ons for [django-compressor](https://github.com/django-compressor/django-compressor/)\nthat simply enables SCSS and ES6 in your Django project.\n\n## Installation\n\n```sh\npip install django-compressor-toolkit\n```\n\n```py\n// settings.py\n\nINSTALLED_APPS += ('compressor_toolkit',)\n```\n\n## Add-ons\n\n### SCSS pre-compiler\n\n[SCSS](http://sass-lang.com/) is a great language that saves your time and brings joy to CSS development.\n\nThe add-on does next:\nSCSS → (\n[node-sass](https://github.com/sass/node-sass) +\n[Autoprefixer](https://github.com/postcss/autoprefixer)\n) → CSS.\n\nIt also enables Django static imports in SCSS, see the example below.\n\n#### Usage\n\n```py\n// settings.py\n\nCOMPRESS_PRECOMPILERS = (\n    ('text/x-scss', 'compressor_toolkit.precompilers.SCSSCompiler'),\n)\n```\n\n```html\n{# Django template #}\n\n{% load compress %}\n\n{% compress css %}\n  \u003clink rel=\"stylesheet\" type=\"text/x-scss\" href=\"{% static 'app/layout.scss' %}\"\u003e\n{% endcompress %}\n```\n\n```scss\n/* app/static/app/layout.scss */\n\n@import \"base/variables\";\n\n.title {\n  font: bold $title-size Arial, sans-serif;\n}\n```\n\n```scss\n/* base/static/base/variables.scss */\n\n$title-size: 30px;\n```\n\n#### Requisites\n\nYou need `node-sass`, `postcss-cli` and `autoprefixer` to be installed. Quick install:\n\n```sh\nnpm install node-sass postcss-cli autoprefixer\n```\n\nOr you can install them globally (you need to set `COMPRESS_LOCAL_NPM_INSTALL = False`):\n\n```sh\nnpm install -g node-sass postcss-cli autoprefixer\n```\n\n### ES6 pre-compiler\n\nES6 is a new standard for JavaScript that brings\n[great new features](https://hacks.mozilla.org/category/es6-in-depth/).\n\nThe standard was approved in July 2015 and not all modern browsers fully support it for now.\nBut there is a way to use it: transpilers that compile ES6 into good old ES5 syntax.\n\nThe add-on does next:\nES6 → (\n[Browserify](http://browserify.org/) +\n[Babelify](https://github.com/babel/babelify)\n) → ES5.\n\nIt also enables Django static imports in ES6, see the example below.\n\n#### Usage\n\n```py\n// settings.py\n\nCOMPRESS_PRECOMPILERS = (\n    ('module', 'compressor_toolkit.precompilers.ES6Compiler'),\n)\n```\n\n```html\n{# Django template #}\n\n{% load compress %}\n\n{% compress js %}\n  \u003cscript type=\"module\" src=\"{% static 'app/scripts.js' %}\"\u003e\u003c/script\u003e\n{% endcompress %}\n```\n\n```js\n// app/static/app/scripts.js\n\nimport Framework from 'base/framework';\n\nnew Framework;\nnew Framework('1.0.1');\n```\n\n```js\n// base/static/base/framework.js\n\nexport let version = '1.0';\n\nexport default class {\n  constructor(customVersion) {\n    console.log(`Framework v${customVersion || version} initialized`);\n  }\n}\n```\n\n#### Requisites\n\nYou need `browserify`, `babelify` and `babel-preset-es2015` to be installed. Quick install:\n\n```sh\nnpm install browserify babelify babel-preset-es2015\n```\n\nOr you can install them globally (you need to set `COMPRESS_LOCAL_NPM_INSTALL = False`):\n\n```sh\nnpm install -g browserify babelify babel-preset-es2015\n```\n\n## Django settings\n\n### `COMPRESS_LOCAL_NPM_INSTALL`\n\nWhether you install required NPM packages _locally_.\n\nDefault: `True`.\n\n### `COMPRESS_NODE_MODULES`\n\nPath to `node_modules` where `babelify`, `autoprefixer`, etc, libs are installed.\n\nDefault: `./node_modules` if `COMPRESS_LOCAL_NPM_INSTALL` else `/usr/lib/node_modules`.\n\n### `COMPRESS_NODE_SASS_BIN`\n\n`node-sass` executable. It may be just the executable name (if it's on `PATH`) or the executable path.\n\nDefault: `./node_modules/.bin/node-sass` if `COMPRESS_LOCAL_NPM_INSTALL` else `node-sass`.\n\n### `COMPRESS_POSTCSS_BIN`\n\n`postcss` executable. It may be just the executable name (if it's on `PATH`) or the executable path.\n\nDefault: `./node_modules/.bin/postcss` if `COMPRESS_LOCAL_NPM_INSTALL` else `postcss`.\n\n### `COMPRESS_AUTOPREFIXER_BROWSERS`\n\nBrowser versions config for Autoprefixer.\n\nDefault: `ie \u003e= 9, \u003e 5%`.\n\n### `COMPRESS_SCSS_COMPILER_CMD`\n\nCommand that will be executed to transform SCSS into CSS code.\n\nDefault:\n\n```py\n'{node_sass_bin} --output-style expanded {paths} \"{infile}\" \"{outfile}\" \u0026\u0026 '\n'{postcss_bin} --use \"{node_modules}/autoprefixer\" --autoprefixer.browsers \"{autoprefixer_browsers}\" -r \"{outfile}\"'\n```\n\nPlaceholders (i.e. they **can be re-used** in custom `COMPRESS_SCSS_COMPILER_CMD` string):\n- `{node_sass_bin}` - value from `COMPRESS_NODE_SASS_BIN`\n- `{postcss_bin}` - value from `COMPRESS_POSTCSS_BIN`\n- `{infile}` - input file path\n- `{outfile}` - output file path\n- `{paths}` - specially for `node-sass`, include all Django app static folders:\n  `--include-path=/path/to/app-1/static/ --include-path=/path/to/app-2/static/ ...`\n- `{node_modules}` - see `COMPRESS_NODE_MODULES` setting\n- `{autoprefixer_browsers}` - value from `COMPRESS_AUTOPREFIXER_BROWSERS`\n\n### `COMPRESS_BROWSERIFY_BIN`\n\n`browserify` executable. It may be just the executable name (if it's on `PATH`) or the executable path.\n\nDefault: `./node_modules/.bin/browserify` if `COMPRESS_LOCAL_NPM_INSTALL` else `browserify`.\n\n### `COMPRESS_ES6_COMPILER_CMD`\n\nCommand that will be executed to transform ES6 into ES5 code.\n\nDefault:\n\n```py\n'export NODE_PATH=\"{paths}\" \u0026\u0026 '\n'{browserify_bin} \"{infile}\" -o \"{outfile}\" '\n'-t [ \"{node_modules}/babelify\" --presets=\"{node_modules}/babel-preset-es2015\" ]'\n```\n\nPlaceholders:\n- `{browserify_bin}` - value from `COMPRESS_BROWSERIFY_BIN`\n- `{infile}` - input file path\n- `{outfile}` - output file path\n- `{paths}` - specially for `browserify`, include all Django app static folders:\n  `/path/to/app-1/static/:/path/to/app-2/static/:...` (like `PATH` variable)\n- `{node_modules}` - see `COMPRESS_NODE_MODULES` setting\n\n## Contribute and test\n\n```sh\ngit clone https://github.com/kottenator/django-compressor-toolkit.git\ncd django-compressor-toolkit\npip install -e '.[test]'\nnpm install\npy.test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkottenator%2Fdjango-compressor-toolkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkottenator%2Fdjango-compressor-toolkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkottenator%2Fdjango-compressor-toolkit/lists"}