question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

rollupOptions.output.assetFileNames does not work

See original GitHub issue

Describe the bug

rollupOptions.output.assetFileNames does not work.

I have the start project with changed config:

export default defineConfig({
  plugins: [vue()],
  build: {
    rollupOptions: {
      output: {
        entryFileNames: `[name].js`,   // works
        chunkFileNames: `[name].js`,   // works
        assetFileNames: `[name].[ext]` // does not work for images
      }
    }
  }
})

The result build structure looks so: image As you can see assetFileNames option was ignored for logo.png.

See the related bug: https://github.com/vitejs/vite/issues/378#issuecomment-789366197

Reproduction

yarn create @vitejs/app my-vue-app --template vue and use the config above.

System Info

Node: 15.9.0
@vitejs/plugin-vue: ^1.2.1 => 1.2.1
vite: ^2.1.5 => 2.1.5

Before submitting the issue, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the docs.
  • Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
  • Provide a description in this issue that describes the bug.
  • Make sure this is a Vite issue and not a framework-specific issue. For example, if it’s a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/vue-next instead.
  • Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:12
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
patak-devcommented, Jul 23, 2021

@patak-js Yes, it works! All files become with name as set in assetFileNames mask. Fonts css ico.

Nice! Thanks for testing

By the way, is it possible to put fonts to font folder? Fonts become as many files as usual and I prefer to put files to font folder and css and ico in root.

Maybe you can specify a different folder depending on the ext of the file? You should join chat.vitejs.dev if you aren’t there already, probably there are others that may have the same requirement to discuss with.

1reaction
Alexufocommented, Jul 23, 2021

@patak-js Yes, it works! All files become with name as set in assetFileNames mask. Fonts css ico.

By the way, is it possible to put fonts to font folder? Fonts become as many files as usual and I prefer to put files to font folder and css and ico in root.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Vite - change ouput directory of assets - Stack Overflow
The output filenames are configured in Rollup with build.rollupOptions : Set output.assetFileNames to configure the asset filenames (for ...
Read more >
rollup.js
During this step, Rollup will build the module graph and perform tree-shaking, but will not generate any output. On a bundle object, you...
Read more >
Configuring Vite
Configuring Vite #. When running vite from the command line, Vite will automatically try to resolve a config file named vite.config.js inside project...
Read more >
Vite not copying all static assets - Laracasts
build: { rollupOptions: { output: { assetFileNames(assetInfo) { const pathToFile ... I am not sure what the problem is and if it is...
Read more >
macropygia/vite-plugin-imagemin-cache - Socket.dev
Dependencies have 4 critical issues. ... no need to use. This is prepared for complex settings in rollupOptions.output.assetFileNames .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found