{"id":20314589,"url":"https://github.com/dashpilot/single-file-components-for-vanilla-js","last_synced_at":"2025-04-11T17:17:34.217Z","repository":{"id":135256600,"uuid":"305008978","full_name":"dashpilot/single-file-components-for-vanilla-js","owner":"dashpilot","description":"Svelte and Vue-inspired single-file components compiler","archived":false,"fork":false,"pushed_at":"2025-02-17T12:30:00.000Z","size":50,"stargazers_count":10,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-25T13:11:29.932Z","etag":null,"topics":["build-script","compiler","nodejs","single-file-components","vanilla-javascript"],"latest_commit_sha":null,"homepage":"single-file-components-for-vanilla-js.vercel.app","language":"HTML","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/dashpilot.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2020-10-18T02:42:09.000Z","updated_at":"2025-02-17T12:30:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"9ff6fd3c-67fe-4968-9148-9e50de81fd84","html_url":"https://github.com/dashpilot/single-file-components-for-vanilla-js","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dashpilot%2Fsingle-file-components-for-vanilla-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dashpilot%2Fsingle-file-components-for-vanilla-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dashpilot%2Fsingle-file-components-for-vanilla-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dashpilot%2Fsingle-file-components-for-vanilla-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dashpilot","download_url":"https://codeload.github.com/dashpilot/single-file-components-for-vanilla-js/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248447600,"owners_count":21105140,"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":["build-script","compiler","nodejs","single-file-components","vanilla-javascript"],"created_at":"2024-11-14T18:15:58.757Z","updated_at":"2025-04-11T17:17:34.205Z","avatar_url":"https://github.com/dashpilot.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# single-file-components-for-vanilla-js\n\nSvelte and Vue-inspired single-file components compiler for vanilla javascript.\n\n## About\n\nInspired by the way Svelte compiles your single file components into browser-friendly javascript, I created a simple compiler for vanilla javascript. You write your code in single-file-component-style, and the build script compiles it to browser-friendly javascript, html and css.\n\nIt also features **live-reload**, so every time you save changes to a single file component, the build script compiles your code and runs it. Although this is a basic POC, in its current form it does help you to better organize your code.\n\n## How to install?\n\n1.  run `npx degit https://github.com/dashpilot/single-file-components-for-vanilla-js`\n2.  run `npm install` and then `npm run dev` to run the example components\n\n## How to create a single-file component?\n\nCreate a new .html file in `src/components`, with the following structure:\n\n    \u003ctemplate\u003e\n    \u003c!-- This is where the html of your component goes --\u003e\n    \u003c/template\u003e\n\n    \u003cscript\u003e\n    // This is where your javascript goes\n    \u003c/script\u003e\n\n    \u003cstyle\u003e\n    /* this is where your CSS goes */\n    \u003c/style\u003e\n\nThe order of the template-, script- and css- tags is up to your own preference. When you run `npm run dev` or `npm run build` the compiler goes through all the components and automatically splits and minifies/uglifies the JS, CSS and HTML into public/assets. It also copies index.html to the public folder.\n\nTo load a component on the page, create a custom element in index.html that corresponds to the filename of your component. For example if your component is called card.html, create a custom element \u003ccard\u003e\u003c/card\u003e in index.html. You can also load multiple instances of the component on the page, without duplicating the javascript or CSS. See `index.html` for an example.\n\n## What it's not\n\nThis script is simply meant to help you write code in a more modular way, but it doesn't feature the wealth of extras Svelte offers (template language, two-way binding, CSS-scoping etc.). Let me know if there are any features/improvements you'd like to see.\n\nIf you do want templating, two-way-binding and a data-store, take a look at the Alpine.js version: \u003chttps://github.com/dashpilot/single-file-components-for-alpinejs\u003e\n\n## Press the :star: button\n\nDon't forget to press the :star: button to let me know I should continue improving this project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdashpilot%2Fsingle-file-components-for-vanilla-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdashpilot%2Fsingle-file-components-for-vanilla-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdashpilot%2Fsingle-file-components-for-vanilla-js/lists"}