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

Despite it's given an InlineConfig object, a secondary build script (with Vite build API JS ) still uses vite.config.js #10177

Closed
7 tasks done
bogacg opened this issue Sep 20, 2022 · 1 comment

Comments

@bogacg
Copy link

bogacg commented Sep 20, 2022

Describe the bug

On top of a primary build using vite.config.js (for multiple pages app) I execute a secondary build script (a build.mjs file) to get several JS files from another source directory into same output dist folder.

With Vite v3.1.2 (and prior) I do not have an issue and output js files are written to dist next to files coming from a previous step as expected.

However after I updated to v3.1.3 today, erroneous output files are written on top of previous ones.

As if Js files of secondary source folder are matched to each input of rollupOptions in defineConfig argument of vite.config.js.

I've prepared an example project with two NPM scripts.
You can see the problem running

  • npm run build: only runs on src folder and then
  • npm run two-builds that executes a custom build script on a secondary source folder after previous default.

Reproduction

https://github.com/bogacg/vite-3-1-3-js-build-api-bug

System Info

System:
    OS: Windows 10 10.0.19043
    CPU: (12) x64 AMD Ryzen 5 3600 6-Core Processor
    Memory: 8.47 GB / 15.92 GB
  Binaries:
    Node: 18.8.0 - C:\Program Files\nodejs\node.EXE
    npm: 8.18.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (105.0.1343.42)
    Internet Explorer: 11.0.19041.1566

Used Package Manager

npm

Logs

No response

Validations

@sapphi-red
Copy link
Member

This behavior was using a bug (#9086).

To stop reading config file automatically for build(), you'll need to set configFile: false.
https://vitejs.dev/guide/api-javascript.html#inlineconfig

  await build({
    build: {
      outDir: "./dist",
      lib: {
        ...lib,
        formats: ["es"],
      },
      emptyOutDir: false
    },
    configFile: false
  });

@sapphi-red sapphi-red closed this as not planned Won't fix, can't repro, duplicate, stale Sep 21, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Oct 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants