Skip to content

plmrry/rollup-plugin-archieml

Repository files navigation

npm size

rollup-plugin-archieml

A Rollup plugin which converts ArchieML files into JavaScript modules.

Install

npm install rollup-plugin-archieml --save-dev

Usage

Create a rollup.config.js configuration file and import the plugin:

import archieml from "rollup-plugin-archieml";

export default {
  input: "src/index.js",
  output: {
    dir: "output",
    format: "cjs",
  },
  plugins: [archieml()],
};

Then call rollup either via the CLI or the API.

Example

Given an ArchieML file called events.aml:

[+events]
  header: My Birthday
  date: August 20th, 1990

  Here's a nice photo

  {.image}
    src: http://example.com/photo.png
    alt: Family Photo
    [.members]
      * Dad
      * Mom
      * Me
    []
  {}
[]

Using this plugin, we can import (or require) the ArchieML file directly:

import events from "./events.aml";

console.dir(events, { depth: null });
// {
//   events: [
//     { type: 'header', value: 'My Birthday' },
//     { type: 'date', value: 'August 20th, 1990' },
//     { type: 'text', value: "Here's a nice photo" },
//     {
//       type: 'image',
//       value: {
//         src: 'http://example.com/photo.png',
//         alt: 'Family Photo',
//         members: [ 'Dad', 'Mom', 'Me' ]
//       }
//     }
//   ]
// }

About

Parse ArchieML files with Rollup

Resources

License

Stars

Watchers

Forks

Packages

No packages published