1.2.0 • Published 3 years ago

@rdx-js/build-rollup-plugin v1.2.0

Weekly downloads
62
License
MIT
Repository
github
Last release
3 years ago

rdx-build-rollup-plugin

Rollup Plugin to process rdx and markdown files

RDX Transpiler Plugin

Simple wrapper around @rdx-js/rdx converts .md and .rdx files to .jsx/.tsx

Use with sucrase or basbel to transpile the generated .jsx/.tsx to .js

Usage in rollup configuration

import { rdxTranspiler } from '@rdx-js/build-rollup-plugin'

// ...

plugins: [
  // :
  resolve(),
  rdxTranspiler(),
  renameExtensions({
    mappings: {
      '.md': '.js',
      '.rdx': '.js'
    }
  }),
  sucrase({
    jsxPragma: 'h',
    production: true,
    exclude: ['node_modules/**'],
    transforms: ['jsx', 'typescript']
  })
]

RDX Packer Plugin

Simple aggregator that converts a dummy index.js in the source folder to a full index of all the transpiled markdown files, including meta data. Creates a single IOPA function that when called registers itself with the Reactive Dialogs manager.

Required Source Repository structure

/
/assets
   image1.jpg
   video1.mp4
markdownfile1.md
markdownfile2.rdx
index.js
global.d.ts
// global.d.ts
declare module "*.md" {
  const value: string;
  export default value;
  export const meta;
}

declare module "*.rdx" {
  const value: string;
  export default value;
  export const meta;
}
// index.ts
// placeholder, replaced with index during rollup phase

Rollup configuration

import { rdxPacker } from '@rdx-js/build-rollup-plugin'

// import other plugins

const dist = 'dist'
const build = 'build'

const external = id =>
  !id.startsWith('.') && !id.startsWith('/') && !id.startsWith('\0')

export default [{
  preserveModules: true,
  input: './src/*.md',
  external,
  output: [
    {
      dir: `${dist}/cjs`,
      format: 'cjs',
      exports: 'named'
    }
  ],
  plugins: [
    rdxPacker(),
    resolve({
      extensions: ['.js', '.ts' ]
    }),
    rdxTranspiler(),
    renameExtensions({
      mappings: {
        '.md': '.js',
        '.rdx': '.js'
      }
    }),
    sucrase({
      jsxPragma: 'h',
      production: true,
      exclude: ['node_modules/**'],
      transforms: ['jsx', 'typescript']
    }),
    terser()
  ]
}

License

MIT

1.2.0

3 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.5.31

5 years ago

0.5.30

5 years ago

0.5.29

5 years ago

0.5.28

5 years ago

0.5.27

5 years ago

0.5.26

5 years ago

0.5.25

5 years ago

0.5.24

5 years ago

0.5.23

5 years ago

0.5.22

5 years ago

0.5.19

5 years ago

0.5.18

5 years ago

0.5.14

5 years ago

0.5.6

5 years ago

0.5.5

5 years ago

0.5.1

5 years ago