Skip to content

v7.2.0 assetsDir is not been applied to all files #13071

Closed

Description

@fernandojbf

I'm using React Router as a...

framework

Reproduction

https://stackblitz.com/edit/github-hjbd1hqq?file=vite.config.ts

Using new version v7.2.0, using assetsDir options in vite.config.ts is not applied to all files.
This was working in previous versions

System Info

System:
    OS: macOS 14.7.3
    CPU: (12) arm64 Apple M2 Pro
    Memory: 101.28 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.16.0 - ~/.nvm/versions/node/v20.16.0/bin/node
    Yarn: 4.6.0 - ~/.nvm/versions/node/v20.16.0/bin/yarn
    npm: 10.8.1 - ~/.nvm/versions/node/v20.16.0/bin/npm
    bun: 1.2.2 - ~/.bun/bin/bun
    Watchman: 2024.11.11.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 133.0.6943.100
    Chrome Canary: 135.0.7025.0
    Safari: 18.1.1

Used Package Manager

yarn

Expected Behavior

all assets should be saved in the assetsDir folder and use that pathname

Actual Behavior

Some assets (i believe entry files) are been added to a asset folder. Other assets are been added to the correct place.

Activity

  1. miguelvictor commented on Feb 20, 2025

    @miguelvictor
    Contributor

    I am also having this problem with the following config:

    export default defineConfig({
      build: { assetsDir: "my-assets/sample" },
      css: { postcss: { plugins: [tailwindcss, autoprefixer] } },
      plugins: [reactRouter(), tsconfigPaths()],
    })
    

    Some of the assets are added to the root while some are inside the defined assetsDir

  2. timdorr commented on Feb 20, 2025

    @timdorr
    Member

    Looks like we've got some hard-coding here:

    return `assets/[name]${routeChunkSuffix}-[hash].js`;

  3. markdalgleish commented on Feb 21, 2025

    @markdalgleish
    Member

    Thanks for raising the issue, I've just merged a fix for this that'll be out in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions