{"id":13447580,"url":"https://github.com/developit/preact-boilerplate","last_synced_at":"2025-05-16T12:11:36.944Z","repository":{"id":3540688,"uuid":"49995432","full_name":"developit/preact-boilerplate","owner":"developit","description":":guitar: Ready-to-rock Preact starter project, powered by Webpack.","archived":false,"fork":false,"pushed_at":"2022-04-28T18:56:27.000Z","size":433,"stargazers_count":964,"open_issues_count":35,"forks_count":183,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-05-13T22:26:40.788Z","etag":null,"topics":["boilerplate","css-modules","development-workflow","preact","pwa","webpack"],"latest_commit_sha":null,"homepage":"https://preact-boilerplate.surge.sh","language":"JavaScript","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/developit.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}},"created_at":"2016-01-20T01:27:33.000Z","updated_at":"2025-04-17T00:57:06.000Z","dependencies_parsed_at":"2022-08-07T07:15:09.791Z","dependency_job_id":null,"html_url":"https://github.com/developit/preact-boilerplate","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developit%2Fpreact-boilerplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developit%2Fpreact-boilerplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developit%2Fpreact-boilerplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developit%2Fpreact-boilerplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/developit","download_url":"https://codeload.github.com/developit/preact-boilerplate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254527099,"owners_count":22085919,"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":["boilerplate","css-modules","development-workflow","preact","pwa","webpack"],"created_at":"2024-07-31T05:01:21.583Z","updated_at":"2025-05-16T12:11:36.929Z","avatar_url":"https://github.com/developit.png","language":"JavaScript","readme":"# Preact Boilerplate / Starter Kit [![Build Status](https://travis-ci.org/developit/preact-boilerplate.svg?branch=master)](https://travis-ci.org/developit/preact-boilerplate) [![Preact Slack Community](https://preact-slack.now.sh/badge.svg)](https://preact-slack.now.sh)\n\n:guitar: Ready-to-rock [Preact] starter project, powered by [webpack]. **[(View Demo)](https://preact-boilerplate.surge.sh)**\n\n\u003e ### :rocket: Note: We now recommend [Preact CLI](https://github.com/developit/preact-cli/) for new projects.\n\u003e\n\u003e [Preact CLI](https://github.com/developit/preact-cli/) is a natural evolution of this boilerplate, and improves on it in every way. In a single dependency, you get a friendly command line project creation and build tool with development \u0026 production modes. Preact CLI requires _no configuration at all_, and even does **automatic code-splitting** without you lifting a finger!  It also produces bundles roughly half the size of preact-boilerplate.\n\n---\n\n\n# Quick-Start Guide\n\n- [Installation](#installation)\n- [Development Workflow](#development-workflow)\n- [Structure](#structure)\n- [CSS Modules](#css-modules)\n- [Handling URLS](#handling-urls)\n- [React Compatibility](#react-compatibility)\n\n\n## Installation\n\n**1. Clone this repo:**\n\n```sh\ngit clone --depth 1 https://github.com/developit/preact-boilerplate.git my-app\ncd my-app\n```\n\n\n**2. Make it your own:**\n\n```sh\nrm -rf .git \u0026\u0026 git init \u0026\u0026 npm init\n```\n\n\u003e :information_source: This re-initializes the repo and sets up your NPM project.\n\n\n**3. Install the dependencies:**\n\n```sh\nnpm install\n```\n\n\u003e You're done installing! Now let's get started developing.\n\n\n\n## Development Workflow\n\n\n**4. Start a live-reload development server:**\n\n```sh\nnpm run dev\n```\n\n\u003e This is a full web server nicely suited to your project. Any time you make changes within the `src` directory, it will rebuild and even refresh your browser.\n\n**5. Testing with `mocha`, `karma`, `chai`, `sinon` via `phantomjs`:**\n\n```sh\nnpm test\n```\n\n\u003e 🌟 This also instruments the code in `src/` using [isparta](https://github.com/douglasduteil/isparta), giving you pretty code coverage statistics at the end of your tests! If you want to see detailed coverage information, a full HTML report is placed into `coverage/`.\n\n**6. Generate a production build in `./build`:**\n\n```sh\nnpm run build\n```\n\n\u003e You can now deploy the contents of the `build` directory to production!\n\u003e\n\u003e **[Surge.sh](https://surge.sh) Example:** `surge ./build -d my-app.surge.sh`\n\u003e \n\u003e **[Netlify](https://www.netlify.com/docs/cli/) Example:** `netlify deploy`\n\u003e\n\u003e [![Deploy to Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/developit/preact-boilerplate)\n\n\n**5. Start local production server with [serve](https://github.com/zeit/serve):**\n\n```sh\nnpm start\n```\n\n\u003e This is to simulate a production (CDN) server with gzip. It just serves up the contents of `./build`.\n\n\n\n---\n\n\n## Structure\n\nApps are built up from simple units of functionality called Components. A Component is responsible for rendering a small part of an application, given some input data called `props`, generally passed in as attributes in JSX. A component can be as simple as:\n\n```js\nclass Link extends Component {\n  render({ to, children }) {\n    return \u003ca href={ to }\u003e{ children }\u003c/a\u003e;\n  }\n}\n// usage:\n\u003cLink to=\"/\"\u003eHome\u003c/Link\u003e\n```\n\n\n---\n\n\n## CSS Modules\n\nThis project is set up to support [CSS Modules](https://github.com/css-modules/css-modules).  By default, styles in `src/style` are **global** (not using CSS Modules) to make global declarations, imports and helpers easy to declare.  Styles in `src/components` are loaded as CSS Modules via [Webpack's css-loader](https://github.com/webpack/css-loader#css-modules).  Modular CSS namespaces class names, and when imported into JavaScript returns a mapping of canonical (unmodified) CSS classes to their local (namespaced/suffixed) counterparts.\n\nWhen imported, this LESS/CSS:\n\n```css\n.redText { color:red; }\n.blueText { color:blue; }\n```\n\n... returns the following map:\n\n```js\nimport styles from './style.css';\nconsole.log(styles);\n// {\n//   redText: 'redText_local_9gt72',\n//   blueText: 'blueText_local_9gt72'\n// }\n```\n\nNote that the suffix for local classNames is generated based on an md5 hash of the file. Changing the file changes the hash.\n\n\n---\n\n\n## Handling URLS\n\n:information_desk_person: This project contains a basic two-page app with [URL routing](https://github.com/preactjs/preact-router).\n\nPages are just regular components that get mounted when you navigate to a certain URL. Any URL parameters get passed to the component as `props`.\n\nDefining what component(s) to load for a given URL is easy and declarative. You can even mix-and-match URL parameters and normal props.\n\n```js\n\u003cRouter\u003e\n  \u003cA path=\"/\" /\u003e\n  \u003cB path=\"/b\" id=\"42\" /\u003e\n  \u003cC path=\"/c/:id\" /\u003e\n\u003c/Router\u003e\n```\n\n\n---\n\n\n## React Compatibility\n\nThis project includes [preact-compat] alias in as `react` and `react-dom` right out-of-the-box.  This means you can install and use third-party React components, and they will use Preact automatically!  It also means that if you _don't_ install third-party React components, `preact-compat` doesn't get included in your JavaScript bundle - it's free if you don't use it 👍\n\n---\n\n\n## License\n\nMIT\n\n\n[Preact]: https://github.com/developit/preact\n[preact-compat]: https://github.com/developit/preact-compat\n[webpack]: https://webpack.github.io\n","funding_links":[],"categories":["JavaScript","Uncategorized"],"sub_categories":["Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevelopit%2Fpreact-boilerplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevelopit%2Fpreact-boilerplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevelopit%2Fpreact-boilerplate/lists"}