npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vite-plugin-dev-manifest

v1.4.0

Published

Vite plugin for generating manifest during dev server

Downloads

6,013

Readme

Vite Plugin Dev Manifest

Vite plugin for generating a dev version of manifest file for backend integration, so you can include script and styles without explicitly knowing what to include.

This way, you can run vite dev server and enjoy cool features, like HMR.

Instalation

# yarn
yarn add -D vite-plugin-dev-manifest

# npm
npm install -D vite-plugin-dev-manifest

Usage

Add it to your Vite config

import { defineConfig } from 'vite';
import devManifest from 'vite-plugin-dev-manifest';

export default defineConfig({
    plugins: [
        devManifest(),
        // ...
    ],

    // ...

    build: {
        // required to create a manifest file
        manifest: true,

        rollupOptions: {
            // specify your input files here, as stated in Vite config https://vitejs.dev/config/#build-rollupoptions
            input: 'src/main.ts'
        }
    }
})

Manifest file will be generated in your dist folder, specified in Vite config. So with default settings it would be something like:

{projectRoot}/dist/manifest.dev.json

Generated manifest will have following structure:

{
    // url to base folder in your local dev server
    "url": "http://localhost:3000/",
    // inputs specified in 'build.rollupOptions.input'
	"inputs": {
		"main": "src/main.ts"
	}
}

It uses your final config to find root, base path and inputs. To retrieve input URL in dev environment, concat it's value with URL like this:

{url}{inputs[input]}

Based on our example, it would be: http://localhost:3000/src/main.ts

NOTE: In manifest file, inputs field is always an object with a keys and values, even if rollupOptions.input is string or an array

Plugin ordering

vite-plugin-dev-manifest forces itself to be registered in later stages, but if more plugins uses enforce: post, it may be needed to order this plugin as the last one, f. ex.: when using along vite-plugin-symfony.

Config

| Name | Type | Default | Description | | -- | -- | -- | -- | | manifestName | string | manifest.dev | name of the generated manifest file in dist folder | | omitInputs | string[] | [] | inputs to omit in generated manifest. It is useful when you want to build some styles or scripts, but not include it in your front app | | delay | number | undefined | you can delay creating of the manifest file if any of the plugins clears dist folder | | clearOnClose | boolean | true | since version 1.2.0 manifest file is being removed, when dev server is closed. To prevent this behaviour, set this flag to false |

Tips

We recommend using vite-plugin-live-reload to reload site when editing your backend files. Don't worry tho, HMR still works for served assets.

License

Library is under MIT License