{"id":22034280,"url":"https://github.com/educationwarehouse/edwh-bundler-plugin","last_synced_at":"2026-05-07T15:46:51.612Z","repository":{"id":152948302,"uuid":"626389619","full_name":"educationwarehouse/edwh-bundler-plugin","owner":"educationwarehouse","description":"Python-only static file (js, css) bundler for `edwh`","archived":false,"fork":false,"pushed_at":"2025-06-26T11:12:39.000Z","size":181,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-18T15:39:52.759Z","etag":null,"topics":["bundler","css","edwh","invoke","javascript","js","python"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/edwh-bundler-plugin/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/educationwarehouse.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-04-11T11:24:30.000Z","updated_at":"2025-06-26T11:12:40.000Z","dependencies_parsed_at":"2024-04-12T16:39:32.084Z","dependency_job_id":"a74cbcfd-f95c-48db-b414-456bb437f24f","html_url":"https://github.com/educationwarehouse/edwh-bundler-plugin","commit_stats":null,"previous_names":[],"tags_count":43,"template":false,"template_full_name":null,"purl":"pkg:github/educationwarehouse/edwh-bundler-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/educationwarehouse%2Fedwh-bundler-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/educationwarehouse%2Fedwh-bundler-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/educationwarehouse%2Fedwh-bundler-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/educationwarehouse%2Fedwh-bundler-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/educationwarehouse","download_url":"https://codeload.github.com/educationwarehouse/edwh-bundler-plugin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/educationwarehouse%2Fedwh-bundler-plugin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274671352,"owners_count":25328432,"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-09-11T02:00:13.660Z","response_time":74,"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":["bundler","css","edwh","invoke","javascript","js","python"],"created_at":"2024-11-30T09:07:45.478Z","updated_at":"2026-05-07T15:46:51.607Z","avatar_url":"https://github.com/educationwarehouse.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# edwh-bundler-plugin\n\n[![PyPI - Version](https://img.shields.io/pypi/v/edwh-bundler-plugin.svg)](https://pypi.org/project/edwh-bundler-plugin)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/edwh-bundler-plugin.svg)](https://pypi.org/project/edwh-bundler-plugin)\n\n-----\n\nEDWH Python-only bundler for static assets (JS and CSS).\nTry it out with an example:\n`edwh bundle.build --input example.yaml --verbose`\n\n**Table of Contents**\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [License](#license)\n- [Changelog](#changelog)\n\n## Installation\n\n```console\npip install edwh-bundler-plugin\n```\n\nBut probably you want to install the whole edwh package:\n\n```console\npipx install edwh[bundler]\n# or\npipx install edwh[plugins,omgeving]\n```\n\n## Usage\n\nAfter setting up a correct `bundle.yaml`, simply run `edwh bundle.build' to build your JS and CSS bundles!\n\n### JS\n\nSince this package is Python-only, it can't do any of the more fancy stuff that nodejs-based bundlers can.\nFor simplistic purposes however, where the bundler is embedded in some other Python workflow, this package could be\nuseful.\nIt can combine JS files (in a naive way) and minify them using [rjsmin](https://pypi.org/project/rjsmin/).\nIn addition to this, it can also add [_hyperscript](https://hyperscript.org) to the bundle and 'minify' it (by removing\ncomments and newlines).\nThese JS and _hs files can be fetched from a remote URL or loaded from a file path.\nCSS files can be also included in the bundle, and will be inlined as `\u003cstyle\u003e`s in the page's head.\nThe same goes for HTML files, which will be appended to the end of the `\u003cbody\u003e` (useful for `\u003ctemplate\u003e`s).\nTypescript files can now also be bundled, using [quickjs](https://pypi.org/project/quickjs/).\nBasic imports should work thanks to a custom resolver, but this hasn't been tested with anything complex such\nas `node_modules` yet.\n\n### CSS\n\n(S)CSS can also be bundled (naively) and minified \n(using [sassquatch](https://pypi.org/project/sassquatch/)/[dart-sass](https://sass-lang.com/dart-sass/)) \nand can also be loaded from either remote or local files.\nA scope can also be defined and using sass all styles in the file will be prefixed with the provided selector.\n\n### Configuration\n\nA bundle with a specific configuration can be built with: `edwh bundle.build --input some.yaml`.\nIf no `--input` is defined, `bundle.yaml` in the current directory will be used.\nThis yaml can contain these keys:\n\n```yaml\njs:\n  - ... # list of resources\ncss:\n  - ... # list of resources\nconfig:\n  minify: bool  # should the outputs be minified?\n  cache: bool   # should CDN resources be cached locally?\n  hash: bool    # should a .hash file be created in addition to the output files?\n  # - and _ are interchangable in variable names:\n  version: 1.2.3 # default: 'latest'\n  output-css: static/css/$filename-$version.css # where should the css be stored?\n  output_js: static/js/$filename-$version.js    # where should the js be stored?\n  scss-variables: # will be available for all .scss files\n    - variables.toml # from a toml, json, yaml file\n    - https://my.site/api/styles.json?secret=${AUTH_TOKEN} # or from a remote file\n\n\n  # extra variables, available via $varname (e.g. see output-css)\n  filename: bundled\n\n\n```\n\n`js` contains input files for the JS bundle, `css` input files for the CSS bundle and `config` contains general\nconfiguration options.\n\n#### JS\n\nThe JS part of the configuration has the following options:\n\n```yaml\njs:\n  - https://some.cdn/mypackage.js   # remote JS file\n  - ./path/to/file.js               # local JS file\n  - https://some.cdn/mypackage._hs  # remote hyperscript file\n  - /path/to/file._hs               # local hyperscript file\n  - \u003e\n    // inline JavaScript (requires starting with a comment so the bundler can detect it)\n    console.log(\"inline multiline js\")\n  - _hyperscript(\"log 'inline hyperscript'\") # if you've included 'hyperscript' from a file or cdn above! Tip: alias `_ = _hyperscript` for ease of use)\n  - https://some.cdn/mystyles.css  # remote CSS (will be inlined in the head)\n  - path/to/styles.css             # local CSS (will be inlined in the head)\n  - path/to/template.html          # will be added to the end of the DOM \n```\n\nSCSS is not supported in this section.\n\n#### CSS\n\n```yaml\ncss:\n  - https://some.cdn/mystyles.scss # remote SCSS\n  - https://some.cdn/mystyles.css  # remote CSS\n  - path/to/styles.scss            # local SCSS\n  - path/to/styles.css             # local CSS\n  - file: url_or_path.css          # dict with options: \n    scope: '#my-style-scope'       # every rule in this file will be scoped\n  - file: url_or_path.css          # transform a .css file with sass\n    scss: 1\n  - |\n    // inline scss or css\n  - file: url_or_path.scss\n    variables: # extra SCSS variables\n      primary: \"#000033\"\n      secondary: \"green\"\n      width: \"20px\"\n  - file: url_or_path.scss\n    variables: # one or more files with variables:\n      - variables.toml                                       # local configuration file (toml, yaml, json, ...)\n      - https://my.site/api/settings.json?secret=${APIKEY}   # remote config file with .env setting for auth \n```\n\nSCSS will be applied if the file extension is `sass` or `scss` or if the scss option is true.\nSCSS will be disabled for files with that extension if the config option is set to false.\nThe `scope` selector can be any CSS selector (e.g. `#id`, `.class`, `element` etc.)\nThe `scope` and `scss` options do not work together, as `scope` always uses scss to add the parent selector.\n\n### Multiple Configurations\n\nYou can define multiple configurations within a single config file to handle different output needs, such as\nminified and unminified versions. Shared assets like JavaScript and CSS files can be defined once and reused across\ndifferent configurations.\n**Example:**\n\n```yaml\n# bundle-multiple.yaml\nshared:\n  js: \u0026shared_js\n    - $input_css/example.ts\n    - $input_css/main2.ts\n  css: \u0026shared_css\n    - $input_css/example.sass\n\nconfigurations:\n  minified:\n    js: *shared_js\n    css: *shared_css\n    config:\n      minify: 1\n      output_js: static/js/bundled.min.js\n      output_css: static/css/bundled.min.css\n\n  unminified:\n    js: *shared_js\n    css: *shared_css\n    config:\n      minify: 0\n      output_js: static/js/bundled.js\n      output_css: static/css/bundled.css\n```\n\nTo compile only one of the configurations in a file, you can use `--name`:\n```bash\nedwh bundle.build --config bundle-multiple.yaml --name minified\n```\n\n\n### CLI Config\n\nThe config options from the config file can be overridden on the command line with the corresponding flags (\nsee `edwh bundle.build -h`).\nBooleans such as `minify` and `cache` can start with 1, 'y' or 't' (e.g. be 1, 'y', 'Y', 'Yes', 'yup', 'true' or\nsomething similar) to be truthy.\nAnything else is considered falsey. The flag `--stdout` can only be used from the commandline, and will yield the result\nto stdout instead of an output file (overrides `--output`)\n\n### Other commands\n\n`edwh bundle.build-js` or `edwh bundle.build-css` can be used to only build one output file (.js or .css respectively).\nThese commands can be used with multiple `--file`s as arguments. The rest of the options are the same as the\nregular `build`.\n\n### Integrated use as an API\n\nInstead of using the cli, this package can also be integrated in other Python scripts.\n\n```python\n# individual helpers\nfrom edwh_bundler_plugin import extract_contents_for_js\nfrom edwh_bundler_plugin import extract_contents_for_css\n\nextract_contents_for_css(\"https://some.cdn/mystyles.css\")  # a {color: red}\nextract_contents_for_js(\"https://some.cdn/mystyles.css\")  # document.head.innerHTML += `\u003cstyle\u003ea {color: red}\u003c/style\u003e`\nextract_contents_for_css(\n    {'file': \"https://some.cdn/assets/css/mystyles.css\", 'scope': '#mydiv'})  # #mydiv a {color: red}\n\n# bundling multiple files\nfrom edwh_bundler_plugin import bundle_js, bundle_css\n\ninline_js = \"\"\"// should start with a comment\n_ = _hyperscript\n\"\"\"\nbundle_js([\"https://unpkg.com/hyperscript.org\", inline_js, \"_(`log 'inline _hs'`)\"])  # returns a string by default\nbundle_css(\n    [\"https://some.cdn/package.css\", {'file': \"./mystyles.css\", 'scope': '#mydiv'}])  # returns a string by default\n```\n\n## License\n\n`edwh-bundler-plugin` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.\n\n## Changelog\n\n[See CHANGELOG.md](CHANGELOG.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feducationwarehouse%2Fedwh-bundler-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feducationwarehouse%2Fedwh-bundler-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feducationwarehouse%2Fedwh-bundler-plugin/lists"}