Webpack loader for Omi.js components

Usage no npm install needed!

<script type="module">
  import omiTemplateLoader from '';



Webpack loader for Omi Single-File Components

You can use npm install or git clone it.

npm install eno-loader --save-dev

Configuration webpack file like this:

module: {
    rules: [{
        test: /\.omi|eno$/,
        use: ['eno-loader']

Loader Demo

Why Eno Loader?

eno-loader is a loader for webpack that allows you to author Omi components in a format called Single-File Components


A *.omi file is a custom file format that uses HTML-like syntax to describe a Omi component. Each *.omi file consists of three types of top-level language blocks: <template>, <script>, and <style>, and optionally additional custom blocks:

<template lang="html">
  <!-- replace render function -->
  <header onClick="${this.test}">${}</header>
import style from './_oHeader.css'
export default {
  css() {
    return style // it will combine scoped css
    console.log('Hello Eno!')
  install() { = {
      title: 'Omi'
/* scoped css */
header {
  height: 50px;
  background-color: #07c160;
  color: white;
  text-align: center;
  line-height: 50px;
  width: 100%;

Single-File Components Demo

It also supports JSX, if you want to do that, you only write <template> without lang="html" attribute in your component like this:

  <header onClick={this.test}>{}</header>

JSX Demo

eno-loader supports using non-default languages, such as CSS pre-processors and compile-to-HTML template languages, by specifying the lang attribute for a language block. For example, you install node-sass after you can use Sass for the style of your component like this:

<style lang="scss">
$height: 50px;
$color: #07c160;
header {
  height: $height;
  background-color: $color;

Sass Demo

There are many cool features provided by eno-loader:

  • Allows using other webpack loaders for each part of a Omi component, for example Sass for <style lang="scss"> and JSX/HTML for <template lang="html">;
  • Allows custom blocks in a .omi or .eno file that can have custom loader chains applied to them Here Online Demo;
  • Treat static assets referenced in <style> and <template> as module dependencies and handle them with webpack loaders (Such as htm, to-string-loader);
  • Simulate scoped CSS for each component (Use Shadow DOM);
  • State-preserving hot-reloading during development.

In a nutshell, the combination of webpack and eno-loader gives you a modern, flexible and extremely powerful front-end workflow for authoring Omi.js applications.