Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate manifest.json file when emitIndex is false #471

Closed
acstll opened this issue Jun 26, 2020 · 6 comments · Fixed by #855
Closed

Generate manifest.json file when emitIndex is false #471

acstll opened this issue Jun 26, 2020 · 6 comments · Fixed by #855

Comments

@acstll
Copy link

acstll commented Jun 26, 2020

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

@underfin
Copy link
Member

underfin commented Jun 27, 2020

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
    })]
  }
}

@acstll
Copy link
Author

acstll commented Jun 30, 2020

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?

@underfin
Copy link
Member

underfin commented Jul 1, 2020

Yeah. I will fix that.See #487.

@acstll
Copy link
Author

acstll commented Jul 3, 2020

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

@underfin underfin closed this as completed Jul 3, 2020
@stephanedemotte
Copy link

stephanedemotte commented Aug 29, 2020

@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 !!

@underfin
Copy link
Member

@stephanedemotte Sorry for later feedback.Fix here #855

@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants