Skip to content

assetsInclude=[] in vite config causes extra file generation and path complications #10926

@colearendt

Description

@colearendt

Describe the bug

Using vite-plugin-web-extension to create a web extension, I happened upon very strange behavior. Namely,

  • files would sometimes be produced at incorrect paths (i.e. if src/popup/popup.html, then output at dist/popup.html
  • some files would get content like export default "/popup.html"
  • error messages like:
Generated an empty chunk: "popup/popup"
"popup.html" overwrites a previously emitted file of the same name

The fix for this behavior was to remove the following line from my vite.config.ts (which was there as a placeholder):

assetsInclude: []

Reproduction

https://github.com/colearendt/extensions-example

Steps to reproduce

  • npm run build
  • notice there is a dist/popup.html file with contents: export default "/popup.html"%
  • remove the assetsInclude: [] line from vite.config.ts
  • Build and notice dist/popup.html has expected contents

System Info

System:
    OS: macOS 12.2.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 91.50 MB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.15.1 - ~/.nvm/versions/node/v16.15.1/bin/node
    Yarn: 1.22.18 - /opt/homebrew/bin/yarn
    npm: 8.11.0 - ~/.nvm/versions/node/v16.15.1/bin/npm
  Browsers:
    Brave Browser: 104.1.42.88
    Chrome: 107.0.5304.110
    Firefox: 106.0.5
    Safari: 15.3
  npmPackages:
    @vitejs/plugin-vue: ^3.2.0 => 3.2.0 
    vite: ^3.2.3 => 3.2.3

Used Package Manager

npm

Logs

 npm run build

> extension-example@0.0.0 build
> vue-tsc && vite build

vite v3.2.3 building for production...

[vite-plugin-web-extension] 
  Building HTML Pages in Multi-Page Mode:
    • src/popup.html
  Building in Lib Mode:
    • (none)

[vite-plugin-web-extension] Building HTML Pages in Multi-Page Mode
✓ 1 modules transformed.
Generated an empty chunk: "popup"
rendering chunks (1)...The emitted file "popup.html" overwrites a previously emitted file of the same name.
../dist/assets/vue.svg   0.48 KiB
../dist/manifest.json    0.28 KiB
../dist/popup.html       0.03 KiB

Validations

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