All Projects → antfu → vite-plugin-package-config

antfu / vite-plugin-package-config

Licence: MIT license
Extend Vite config from your package.json `vite` field.

Programming Languages

typescript
32286 projects
HTML
75241 projects
CSS
56736 projects

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].