@riotjs/parcel-plugin-riot

6.0.0 • Public • Published

Build Status NPM version NPM downloads MIT License

A parcel plugin for riot.js

Important

If you are using Riot.js < 4.0.0 please check the v3 branch

Using

Add parcel-plugin-riot to your project.

npm i -D @riotjs/parcel-plugin-riot @riotjs/compiler

-> You are ready!

import App from './src/App.riot'
import {component} from 'riot'

component(App)(document.querySelector('#root'), {
  message: 'Hello there'
})

Configuration

If you want compile your tags using custom riot compiler options you can create a riot.config.js in the root folder of your project

module.exports = {
  hot: false // set it to true if you are using hmr
  // add here all the other @riotjs/compiler options riot.js.org/compiler
  // template: 'pug' for example
}

If you want to use pug as your template engine, your riot.config.js might look like this

const { registerPreprocessor } = require('@riotjs/compiler')
const { render } = require('pug')

// register the pug preprocessor
registerPreprocessor('template', 'pug', (code, options) => {
  const { file } = options

  return {
    code: render(code, {
      filename: file,
      pretty: true,
      doctype: 'html'
    })
  }
})

module.exports = {
  template: 'pug'
}

If you want to enable hmr via hot option you will need to install also @riotjs/hot-reload

npm i @riotjs/hot-reload -D

Readme

Keywords

none

Package Sidebar

Install

npm i @riotjs/parcel-plugin-riot

Weekly Downloads

2

Version

6.0.0

License

MIT

Unpacked Size

6.89 kB

Total Files

12

Last publish

Collaborators

  • gianlucaguarini