{"id":13665409,"url":"https://github.com/PolymerX/lit-loader","last_synced_at":"2025-04-26T08:32:09.583Z","repository":{"id":143886475,"uuid":"133932814","full_name":"PolymerX/lit-loader","owner":"PolymerX","description":"LitElement Single File Component loader for Webpack.","archived":false,"fork":false,"pushed_at":"2020-06-03T09:20:19.000Z","size":2533,"stargazers_count":94,"open_issues_count":12,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-04T01:05:17.412Z","etag":null,"topics":["lit-html","litelement","polymer","postcss","webpack"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/PolymerX.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2018-05-18T09:24:30.000Z","updated_at":"2023-08-06T12:56:20.000Z","dependencies_parsed_at":"2023-07-30T23:31:39.622Z","dependency_job_id":null,"html_url":"https://github.com/PolymerX/lit-loader","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PolymerX%2Flit-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PolymerX%2Flit-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PolymerX%2Flit-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PolymerX%2Flit-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PolymerX","download_url":"https://codeload.github.com/PolymerX/lit-loader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224031926,"owners_count":17244361,"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":["lit-html","litelement","polymer","postcss","webpack"],"created_at":"2024-08-02T06:00:37.269Z","updated_at":"2024-11-11T00:30:46.065Z","avatar_url":"https://github.com/PolymerX.png","language":"JavaScript","funding_links":[],"categories":["Tools"],"sub_categories":[],"readme":"# lit-loader\n[![Build Status](https://travis-ci.org/PolymerX/lit-loader.svg?branch=master)](https://travis-ci.org/PolymerX/lit-loader) [![codecov](https://codecov.io/gh/PolymerX/lit-loader/badge.svg?branch=master)](https://codecov.io/gh/PolymerX/lit-loader?branch=master)\n[![Greenkeeper badge](https://badges.greenkeeper.io/PolymerX/lit-loader.svg)](https://greenkeeper.io/)\n\n[![npm](https://img.shields.io/npm/v/lit-loader.svg?style=for-the-badge)](https://github.com/PolymerX/lit-loader)\n\n\u003e Single File Component LitElement loader for Webpack\n\n## Example repository\n\nCheckout the working repository for a more comprehensive example: https://github.com/PolymerX/lit-loader-example\n\n## Why\n\nBecause we love separation of concerns also without separation of files! This loader will produce a Web Component using the [LitElement](https://github.com/Polymer/lit-element) starting from a Single File Component, [like Vue](https://vuejs.org/v2/guide/single-file-components.html).\n\n## What\n\nThe loader does a simple job: take your `.lit` file and build up as single `js` file. And you can easily use **PostCSS** on your styles.\n\n\n## Install\n\n```\n$ yarn add --dev lit-loader\n```\n\n## Usage\n\n#### Add to Webpack\n\nAdd the loader to your Webpack conf `webpack.config.js`:\n\n```js\n...\n\nmodule: {\n    rules: [\n      {\n        test: /\\.lit$/,\n        loader: 'lit-loader'\n      }\n    ]\n  }\n\n...\n```\n\n#### Create your first `.lit` element\n\n`CounterElement.lit`\n```html\n\u003cstyle lang=\"postcss\"\u003e \u003c!-- This will enable PostCSS compilation --\u003e\n  span {\n    width: 20px;\n    display: inline-block;\n    text-align: center;\n    font-weight: bold;\n  }\n\u003c/style\u003e\n\n\u003ctemplate\u003e\n  \u003cdiv\u003e\n    \u003cp\u003e\n      Clicked: \u003cspan\u003e${this.clicks}\u003c/span\u003e times.\n      Value is \u003cspan\u003e${this.value}\u003c/span\u003e.\n      \u003cbutton @click=\"${this._onIncrement}\" title=\"Add 1\"\u003e+\u003c/button\u003e\n      \u003cbutton @click=\"${this._onDecrement}\" title=\"Minus 1\"\u003e-\u003c/button\u003e\n    \u003c/p\u003e\n  \u003c/div\u003e\n\u003c/template\u003e\n\n\u003cscript\u003e\n  export default class CounterElement {\n    static get properties() { return {\n      clicks: Number,\n      value: Number\n    }};\n\n    constructor() {\n      super();\n      this.clicks = 0;\n      this.value = 0;\n    }\n\n    _onIncrement() {\n      this.value++;\n      this.clicks++;\n      this.dispatchEvent(new CustomEvent('counter-incremented'));\n    }\n\n    _onDecrement() {\n      this.value--;\n      this.clicks++;\n      this.dispatchEvent(new CustomEvent('counter-decremented'));\n    }\n  }\n\n  window.customElements.define('counter-element', CounterElement);\n\u003c/script\u003e\n```\n\n#### Import it within another element and use it\n\n`index.js`\n```js\nimport {LitElement, html} from 'lit-element';\n\n...\n\nimport './CounterElement.lit';\n\nexport default class MyApp extends LitElement {\n\t...\n\n\n\t_render(props) {\n\t\treturn html`\n\t\t\u003cdiv\u003e\n\t\t\t\u003ccounter-element\u003e\u003c/counter-element\u003e\n\t\t\u003c/div\u003e\n\t\t`\n\t}\n\n\t...\n\n}\n\n```\n\n## Use with Babel\n\nJust chain the `babel-loader` **AFTER** the `lit-loader` like so:\n\n```js\nmodule: {\n    rules: [\n      {\n        test: /\\.lit$/,\n        use: ['babel-loader', 'lit-loader']\n      }\n    ]\n  }\n```\n\n## PostCSS configuration\n\nYou need to add a PostCSS configuration file (`postcss.config.js`) if you want to use it.\n\n## Current status\n\nI think this should be considered experimental and I will try to improve it as much as I can. I really would love to accept some PR's to improve the project. 🤘\n\n\n## License\n\nMIT © [LasaleFamine](https://godev.space)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPolymerX%2Flit-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FPolymerX%2Flit-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPolymerX%2Flit-loader/lists"}