On this page:
- Install pre-requisites
- Create a new LitElement project
- Serve your project locally
- Build your project for production
Install pre-requisites
To work locally with lit-element, you'll first need to install Git, npm and Node.js, and the Polymer CLI.
-
Update npm:
bash npm install -g npm@latest
-
Install Polymer CLI:
bash npm install -g polymer-cli@latest
Create a new LitElement project
mkdir myproject
cd myproject
npm init -y
npm install --save @polymer/lit-element
npm install --save @webcomponents/webcomponentsjs
Serve
Create a polymer.json config file, and serve your project:
cd myproject
npm install
echo '{
"npm": true,
"moduleResolution": "node",
"entrypoint": "src/index.html",
"shell": "src/my-project.js",
"extraDependencies": [
"node_modules/@webcomponents/webcomponentsjs/**"
],
"builds": [{
"name": "mybuild",
"bundle": true,
"js": {
"minify": true
}
}]
}' >polymer.json
polymer serve
See the docs for more information on working with Polymer CLI.
Build
Build your project, and serve the build locally:
cd myproject
polymer build
polymer serve build/mybuild
For more information on building LitElement projects see Build for production.