Vite: Generate manifest.json file when emitIndex is false

Created on 26 Jun 2020  Â·  6Comments  Â·  Source: vitejs/vite

Is your feature request related to a problem? Please describe.
I'd like to use Vite for plain old websites, where I add some JavaScript, nothing fancy (I currently use Webpack for this).

Describe the solution you'd like
I would like Vite to generate a manifest.json file when the emitIndex option is false, so I can use it to print the paths to the assets myself based on that file… This is the plugin I use now with Webpack (https://github.com/danethurber/webpack-manifest-plugin).

Describe alternatives you've considered
Using an existing Rollup plugin but there's no way, that I know of, to configure "global" plugins (not "input" or "output")…

Additional context
I recently used Vite to build an app with Preact, and I'm feeling like in #461

Most helpful comment

@stephanedemotte Sorry for later feedback.Fix here https://github.com/vitejs/vite/pull/855

All 6 comments

You can use https://github.com/shuizhongyueming/rollup-plugin-output-manifest/tree/master/packages/main and add this pulgin into vite.config.js.like this

export default {
rollupInputOptions: {
    plugins: [require('rollup-plugin-output-manifest')({
      outputPath: __dirname,
      filter: a => !!a
    })]
  }
}

Thanks for the super quick reply!

It worked like this:

import outputManifest from 'rollup-plugin-output-manifest'
import { join } from 'path'

export default {
  emitIndex: false,
  rollupInputOptions: {
    plugins: [outputManifest({
      outputPath: join(__dirname, 'public'),
      filter: a => !!a
    })]
  }
}

I would have wanted the manifest.json file to be right inside the dist/_assets folder but that doesn't work. I guess it gets overwritten by a new dist folder as the final output of the bundle, no?

Yeah. I will fix that.See https://github.com/vitejs/vite/pull/487.

✨ it works now in beta.10, thank you! We can close this…

@underfin How can we retrieve the style.css hashed file name ?

With rollup-plugin-output-manifest we get only the js file.

{
  "index.js": "index.2d5ca451.js"
}

Thanks !!

@stephanedemotte Sorry for later feedback.Fix here https://github.com/vitejs/vite/pull/855

Was this page helpful?
0 / 5 - 0 ratings