JSPM

vite-plugin-package-config

0.1.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6853
  • Score
    100M100P100Q124825F
  • License MIT

Extend Vite config from package.json field

Package Exports

  • vite-plugin-package-config
  • vite-plugin-package-config/dist/index.js
  • vite-plugin-package-config/dist/index.mjs

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (vite-plugin-package-config) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

vite-plugin-package-config

NPM version

Extend Vite config from your package.json vite field.

// package.json
{
  // ...
  "vite": {
    "resolve": {
      "alias": {
        "~/": "src/"
      }
    },
    "build": {
      "output": "dist/"
    }
  }
}

Install

npm i -D vite-plugin-package-config

Add plugin to your vite.config.ts:

// vite.config.ts
import PkgConfig from 'vite-plugin-package-config'

export default {
  plugins: [
    PkgConfig()
  ]
}

Why?

Well, I know you can always have those configurations in your vite.config.ts file. But, aware the file is in JavaScript / TypeScript, it is not that friendly to be statically analyzed. By putting some of the static configurations in your package.json file, you can have it shareable for other scripts and tools (or even manipulate it) by simply loading and parsing the JSON file.

Sponsors

License

MIT License © 2021 Anthony Fu