Skip to content

mikhail-ev/lit-project-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lit-project-template

Example of lit-element project powered by stringify-jsx.

stringify-jsx configuration

To be able to use @event, .value and ?boolean bindings that are not valid in JSX the following configuration has been used:

stringifyJsx({
    customAttributeReplacementFn: (nodePath, defaultReplacement) => {
        if (defaultReplacement) {
        return defaultReplacement;
        }
        const attribute = nodePath.node.name;
        if (attribute.startsWith('a-')) {
        return '@' + attribute.slice(2);
        }
        if (attribute.startsWith('d-')) {
        return '.' + attribute.slice(2);
        }
        if (attribute.startsWith('q-')) {
        return '?' + attribute.slice(2);
        }
        return attribute;
    }
}, {
    plugins: ["@babel/plugin-syntax-dynamic-import"]
})

Thus this code:

<input a-input={this.handleInput}/>

Will be transformed into

<input @input="${this.handleInput}"/>

Full configuration can be found in rollup.config.js

About

Lit-element project template powered by typescript, redux and stringify-jsx

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors