UNPKG

unplugin-bid

Version:

Import .bid files as strings 🧵 in Vite, Rollup, Webpack + more

102 lines • 4.94 kB
{ "name": "unplugin-bid", "version": "0.1.2", "description": "Import .bid files as strings 🧵 in Vite, Rollup, Webpack + more", "keywords": [ "unplugin", "vite", "webpack", "rollup", "transform", "three.js", "svelte-cubed", "bid", "bid-loader", "bid-file" ], "homepage": "https://github.com/tonyketcham/unplugin-bid#readme", "bugs": { "url": "https://github.com/tonyketcham/unplugin-bid/issues" }, "author": { "name": "Tony Ketcham", "email": "ketcham.dev@gmail.com", "url": "https://github.com/tonyketcham" }, "repository": { "type": "git", "url": "git+https://github.com/tonyketcham/unplugin-bid.git" }, "license": "MIT", "exports": { ".": { "require": "./dist/index.js", "import": "./dist/index.mjs" }, "./vite": { "require": "./dist/vite.js", "import": "./dist/vite.mjs" }, "./webpack": { "require": "./dist/webpack.js", "import": "./dist/webpack.mjs" }, "./rollup": { "require": "./dist/rollup.js", "import": "./dist/rollup.mjs" }, "./nuxt": { "require": "./dist/nuxt.js", "import": "./dist/nuxt.mjs" }, "./types": { "require": "./dist/types.js", "import": "./dist/types.mjs" }, "./*": "./*", "./bid": { "types": "./bid.d.ts" } }, "main": "dist/index.js", "module": "dist/index.mjs", "types": "index.d.ts", "files": [ "dist", "types", "*.d.ts" ], "dependencies": { "unplugin": "^0.2.7" }, "devDependencies": { "@types/node": "^16.7.10", "@typescript-eslint/eslint-plugin": "^5.5.0", "@typescript-eslint/parser": "^5.5.0", "bumpp": "^6.1.0", "eslint": "^7.32.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-prettier": "^4.0.0", "esno": "^0.9.1", "fast-glob": "^3.2.7", "nodemon": "^2.0.12", "prettier": "^2.5.0", "rimraf": "^3.0.2", "rollup": "^2.56.3", "tsup": "^4.14.0", "typescript": "^4.5", "vite": "^2.5.3", "webpack": "^5.51.2" }, "scripts": { "build": "tsup", "dev": "tsup --watch src", "build:fix": "esno scripts/postbuild.ts", "lint": "eslint \"{src,test}/**/*.ts\"", "lint:fix": "npm run lint -- --fix", "format": "prettier --config .prettierrc 'src/**/*.ts' --write", "release": "pnpm publish", "start": "esno src/index.ts" }, "readme": "# unplugin-bid\n\n[![NPM version](https://img.shields.io/npm/v/unplugin-bid?color=a1b858&label=)](https://www.npmjs.com/package/unplugin-bid)\n\nAn [`.bid`](https://en.wikipedia.org/wiki/Wavefront_.bid_file) file import plugin for Vite, Rollup, and Webpack; built with [unplugin](https://github.com/unjs/unplugin). This gives you a sweet and simple way to import an `.bid` file as a string to, for example, parse into a mesh in something like [three.js](https://threejs.org/), or do whatever you want with.\n\n## Usage\n\nHere's a simple example which imports an `.bid` file as a string then logs it to the console.\n\n```ts\nimport bid from './models/Lowpoly_tree_sample.bid';\n\nconsole.log(bid);\n\n// ...optionally parse the bid file and create a mesh from it...\n```\n\n> 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\n\n## Install\n\n```bash\npnpm i -D unplugin-bid\n```\n\n## Types\n\nThe most generally compatible way to add type definitions for `.bid` modules is via a `tsconfig.json` file.\n\n```js\n// tsconfig.json\n{\n \"compilerOptions\": {\n ...\n \"types\": [\"unplugin-bid/bid\"]\n }\n}\n```\n\n### Vite\n\n```ts\n// vite.config.ts\nimport bidFileImport from 'unplugin-bid/vite';\n\nexport default defineConfig({\n plugins: [bidFileImport()],\n});\n```\n\nOptional method to add types w/o `tsconfig`:\n\n```ts\n// vite-env.d.ts\n/// <reference types=\"unplugin-bid/bid\" />\n```\n\n### Rollup\n\n```ts\n// rollup.config.js\nimport bidFileImport from 'unplugin-bid/rollup';\n\nexport default {\n plugins: [bidFileImport()],\n};\n```\n\n### Webpack\n\n```ts\n// webpack.config.js\nmodule.exports = {\n /* ... */\n plugins: [require('unplugin-bid/webpack')()],\n};\n```\n\n### SvelteKit\n\n```ts\n// svelte.config.js\n/* ... */\nimport bidFileImport from 'unplugin-bid/vite';\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n /* ... */\n kit: {\n /* ... */\n vite: {\n /* ... */\n plugins: [bidFileImport()],\n },\n },\n};\n\nexport default config;\n```\n\n### Nuxt\n\n```ts\n// nuxt.config.js\nexport default {\n buildModules: [['unplugin-bid/nuxt']],\n};\n```\n\n> This module works for both Nuxt 2 and [Nuxt Vite](https://github.com/nuxt/vite)\n\n### Vue CLI\n\n```ts\n// vue.config.js\nmodule.exports = {\n configureWebpack: {\n plugins: [require('unplugin-bid/webpack')()],\n },\n};\n```\n" }