unplugin-bib
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

unplugin-bib

NPM version

An .bib file import plugin for Vite, Rollup, and Webpack; built with [unplugin](https://github.com/unjs/unplugin and https://github.com/tonyketcham/unplugin-obj https://github.com/antfu). This gives you a sweet and simple way to import an .bib file as a string to.

Usage

Here's a simple example which imports an .bib file as a string then logs it to the console.

import bib from './file.bib';

console.log(bib);

// ...optionally parse the bib file and create a mesh from it...

TypeSript & eslint may yell at you for trying to import a module where one doesn't exist without this plugin, so you can ask it to stop using the above comments before the import

Install

pnpm i -D unplugin-bib

Types

The most generally compatible way to add type definitions for .bib modules is via a tsconfig.json file.

// tsconfig.json
{
  "compilerOptions": {
    ...
    "types": ["unplugin-bib/bib"]
  }
}

Vite

// vite.config.ts
import bibFileImport from 'unplugin-bib/vite';

export default defineConfig({
  plugins: [bibFileImport()],
});

Optional method to add types w/o tsconfig:

// vite-env.d.ts
/// <reference types="unplugin-bib/bib" />

Rollup

// rollup.config.js
import bibFileImport from 'unplugin-bib/rollup';

export default {
  plugins: [BibFileImport()],
};

Webpack

// webpack.config.js
module.exports = {
  /* ... */
  plugins: [require('unplugin-bib/webpack')()],
};

SvelteKit

// svelte.config.js
/* ... */
import bibFileImport from 'unplugin-bib/vite';

/** @type {import('@sveltejs/kit').Config} */
const config = {
  /* ... */
  kit: {
    /* ... */
    vite: {
      /* ... */
      plugins: [bibFileImport()],
    },
  },
};

export default config;

Nuxt

// nuxt.config.js
export default {
  buildModules: [['unplugin-bib/nuxt']],
};

This module works for both Nuxt 2 and Nuxt Vite

Vue CLI

// vue.config.js
module.exports = {
  configureWebpack: {
    plugins: [require('unplugin-bib/webpack')()],
  },
};

Package Sidebar

Install

npm i unplugin-bib

Weekly Downloads

0

Version

0.1.2

License

MIT

Unpacked Size

13 kB

Total Files

26

Last publish

Collaborators

  • gdeioannes