-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it possible to use hybrids without a build process ? #50
Comments
Of course, you can :) Your example shows how to use hybrids in mode, which supports older browsers. However, it might not be the best option to create standalone web components with own entry. If you target ES modules ready browsers, you can serve and use single file import { define, html } from 'https://unpkg.com/hybrids@2.0.2/src/index.js';
function increaseCount(host) {
host.count += 1;
}
const SimpleCounter = {
count: 0,
render: ({ count }) => html`
<button onclick="${increaseCount}">
Count: ${count}
</button>
`,
};
define('simple-counter', SimpleCounter); And simply use it in html: <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Simple Counter Example</title>
<!-- IMPORT SIMPLE COUNTER -->
<script type="module" src="https://your-domain.com/simple-counter.js"></script>
<!-- IMPORT SIMPLE COUNTER -->
</head>
<body>
<simple-counter count="10"></simple-counter>
</body>
</html> Some highlights:
|
Thanks :-) I like being able to refine and optimize at a later stage if needed. |
Feel free to reopen if you have any additional questions. |
Could you please provide a hint or two to write components without Webpack to get going?
It would seem a nice workflow to use a component by just importing the pre-built js and import one or two components on the page and leverage caching for pages primarily consisting of the occasional component. ES6+ only is fine.
I read a couple of writeup for Vue, but I´m not skilled enough to translate into something that would apply to hybrids:
https://markus.oberlehner.net/blog/goodbye-webpack-building-vue-applications-without-webpack/
https://medium.com/@steveolensky/create-a-spa-vuejs-application-without-node-webpack-or-any-other-build-process-using-vue-router-b9bf8e36e958
I´m not sure if this is a reasonable way to go about it by referencing window.hybrids
Regards,
The text was updated successfully, but these errors were encountered: