Last active
June 17, 2020 20:21
-
-
Save ZiTAL/a61f10ef79e53d0cd428cc03d3ec4e07 to your computer and use it in GitHub Desktop.
lit-element: webpack example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir -p /home/projects/lit/src/components | |
cd /home/projects/lit | |
npm init -y | |
npm install lit-element webpack webpack-cli --save-dev | |
touch index.html | |
touch src/index.js | |
touch src/components/progress-bar.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# builds dist/main.js with webpack | |
npm start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
</head> | |
<body> | |
<progress-bar></progress-bar> | |
<script src="dist/main.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// /home/projects/lit/src/index.js | |
import "./components/progress-bar.js" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "lit", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"start": "webpack" | |
}, | |
"keywords": [], | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"lit-element": "^2.3.1", | |
"webpack": "^4.43.0", | |
"webpack-cli": "^3.3.11" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// /home/projects/lit/src/components/progress-bar.js | |
import {LitElement, html} from 'lit-element'; | |
class ProgressBar extends LitElement { | |
render() { | |
return html` | |
<div>Hello from MyElement!</div> | |
`; | |
} | |
} | |
window.customElements.define('progress-bar', ProgressBar); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
php -S localhost:8000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment