• Stars
    star
    180
  • Rank 213,097 (Top 5 %)
  • Language
    JavaScript
  • License
    BSD 3-Clause "New...
  • Created over 3 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

web components 测试

LitElement TypeScript starter

This project includes a sample component using LitElement with TypeScript.

Setup

Install dependencies:

npm i

Build

This sample uses the TypeScript compiler to produce JavaScript that runs in modern browsers.

To build the JavaScript version of your component:

npm run build

To watch files and rebuild when the files are modified, run the following command in a separate shell:

npm run build:watch

Both the TypeScript compiler and lit-analyzer are configured to be very strict. You may want to change tsconfig.json to make them less strict.

Testing

This sample uses modern-web.dev's @web/test-runner along with Mocha, Chai, and some related helpers for testing. See the modern-web.dev testing documentation for more information.

Tests can be run with the test script:

npm test

Dev Server

This sample uses modern-web.dev's @web/dev-server for previewing the project without additional build steps. Web Dev Server handles resolving Node-style "bare" import specifiers, which aren't supported in browsers. It also automatically transpiles JavaScript and adds polyfills to support older browsers. See modern-web.dev's Web Dev Server documentation for more information.

To run the dev server and open the project in a new browser tab:

npm run serve

There is a development HTML file located at /dev/index.html that you can view at http://localhost:8000/dev/index.html.

Editing

If you use VS Code, we highly recommend the lit-plugin extension, which enables some extremely useful features for lit-html templates:

  • Syntax highlighting
  • Type-checking
  • Code completion
  • Hover-over docs
  • Jump to definition
  • Linting
  • Quick Fixes

The project is setup to recommend lit-plugin to VS Code users if they don't already have it installed.

Linting

Linting of TypeScript files is provided by ESLint and TypeScript ESLint. In addition, lit-analyzer is used to type-check and lint lit-html templates with the same engine and rules as lit-plugin.

The rules are mostly the recommended rules from each project, but some have been turned off to make LitElement usage easier. The recommended rules are pretty strict, so you may want to relax them by editing .eslintrc.json and tsconfig.json.

To lint the project run:

npm run lint

Formatting

Prettier is used for code formatting. It has been pre-configured according to the Polymer Project's style. You can change this in .prettierrc.json.

Prettier has not been configured to run when committing files, but this can be added with Husky and and pretty-quick. See the prettier.io site for instructions.

Static Site

This project includes a simple website generated with the eleventy static site generator and the templates and pages in /docs-src. The site is generated to /docs and intended to be checked in so that GitHub pages can serve the site from /docs on the master branch.

To enable the site go to the GitHub settings and change the GitHub Pages "Source" setting to "master branch /docs folder".

To build the site, run:

npm run docs

To serve the site locally, run:

npm run docs:serve

To watch the site files, and re-build automatically, run:

npm run docs:watch

The site will usually be served at http://localhost:8000.

Bundling and minification

This starter project doesn't include any build-time optimizations like bundling or minification. We recommend publishing components as unoptimized JavaScript modules, and performing build-time optimizations at the application level. This gives build tools the best chance to deduplicate code, remove dead code, and so on.

For information on building application projects that include LitElement components, see Build for production on the Lit site.

More information

See Get started on the Lit site for more information.

More Repositories

1

HappyEliminate

开心消消乐-Vue版
Vue
241
star
2

react-webpack5-template

webpack5 react 项目模板,支持 typescript,使用 SWC 编译,体验超快速度
JavaScript
196
star
3

AEditor

一个基于 Vue 可以输入公式的富文本编辑器
JavaScript
188
star
4

TestPaperCenter

试题管理系统
JavaScript
184
star
5

collegeCourse

🔥 各大高校课表获取代码,更新中......
Java
183
star
6

FE-BLOG

一个前端仔的博客,里面也有自己做过的一些开源项目介绍~
MDX
183
star
7

Pikachu

TypeScript
182
star
8

hmr-demo

由 Demo 演示 webpack 与 Vite 的 HMR 原理
181
star
9

jacob-lcs

个人简介
181
star
10

imagequant-wasm

Rust
180
star
11

nestjs-ctrip-apollo

将携程 apollo 适配 nestjs 依赖注入开发模式
180
star
12

color-cube

多彩立方体,基于 three.js
JavaScript
180
star
13

intellij-gitlab-pull-request-plugin

适配 gitlab 的 pull request 工具
Kotlin
180
star
14

crawlCourse

🎯爬取网易云课堂、腾讯课堂等网站的课程信息
Python
12
star
15

awesome-curriculum-web

🚀 专为大学生打造的课程表软件-React版
TypeScript
10
star
16

curriculum_helper

课表时间管理app-Android
Java
8
star
17

lodash-source-code-analysis

lodash v4.x 源码解析
JavaScript
5
star
18

qcwy_data

前程无忧网站数据爬取,采用scrapy框架
Python
3
star
19

blog

一个前端的博客,如果对你有帮助,还请点个 star ✨
3
star
20

sug_wxyun

权益中心小程序-云开发版
JavaScript
3
star
21

awesome-curriculum-android

🔥 Android版课程助手
Java
2
star
22

Educational_management_system

教务管理系统
Vue
2
star
23

why-vite-is-so-fast

使用 Slidev 演示 Vite 为什么这么快
2
star
24

IT-BigData

IT工资大数据
JavaScript
1
star
25

suggestions

权益中心小程序
JavaScript
1
star
26

vue-template-vite

Vue 项目模板,PC 端布局,配置有 element-plus 按需加载、eslint、stylelint 等
Vue
1
star
27

wanglou

👁‍🗨望楼前端监控系统
JavaScript
1
star