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

NxAppWebpackPlugin outputFileName option does not work as expected #26441

Closed
1 of 4 tasks
tbinna opened this issue Jun 7, 2024 · 2 comments
Closed
1 of 4 tasks

NxAppWebpackPlugin outputFileName option does not work as expected #26441

tbinna opened this issue Jun 7, 2024 · 2 comments
Assignees
Labels
outdated scope: bundlers Issues related to webpack, rollup stale type: bug

Comments

@tbinna
Copy link

tbinna commented Jun 7, 2024

Current Behavior

If you use the NxAppWebpackPlugin in a project with the outputFileName option to rename the output file, you always get two files, a main.js and whatever is configured in the outputFileName.

Expected Behavior

I'd expect to only get one file in the output that matches the option in outputFileName, instead of an additional main.js.

GitHub Repo

/~https://github.com/tbinna/nx-webpack-test

Steps to Reproduce

The repository includes a workspace with the default node application generator output. The only change I made is to add the outputFileName option to have the output named index.js instead of main.js.

  1. run nx build node-app
  2. go to dist/apps/node-app, where there is now an index.js and a main.js file

Nx Report

Node   : 20.13.1
OS     : darwin-arm64
npm    : 10.5.2

nx (global)        : 19.2.0
nx                 : 19.2.1
@nx/js             : 19.2.1
@nx/jest           : 19.2.1
@nx/linter         : 19.2.1
@nx/eslint         : 19.2.1
@nx/workspace      : 19.2.1
@nx/devkit         : 19.2.1
@nx/eslint-plugin  : 19.2.1
@nx/node           : 19.2.1
@nrwl/tao          : 19.2.1
@nx/web            : 19.2.1
@nx/webpack        : 19.2.1
typescript         : 5.4.5
---------------------------------------
Registered Plugins:
@nx/webpack/plugin
@nx/eslint/plugin
@nx/jest/plugin

Failure Logs

No response

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

I have been debugging this issue and managed to trace it to the call of applyBaseConfig. The second argument to this call, compiler.options contains a default entry for main. The Nx plugin will append any entries it calculates to the existing entries, which means if we rename the output, we always get the default main plus any other entries that the plugin added.

Below is the debug console for that particular call, which shows the default main entry.

image

Copy link

github-actions bot commented Dec 5, 2024

This issue has been automatically marked as stale because it hasn't had any activity for 6 months.
Many things may have changed within this time. The issue may have already been fixed or it may not be relevant anymore.
If at this point, this is still an issue, please respond with updated information.
It will be closed in 21 days if no further activity occurs.
Thanks for being a part of the Nx community! 🙏

@github-actions github-actions bot added the stale label Dec 5, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 27, 2024
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 27, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: bundlers Issues related to webpack, rollup stale type: bug
Projects
None yet
Development

No branches or pull requests

3 participants