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

Scripts: Filename changes to main.js when ouput-path parameter is added #34239

Closed
Soean opened this issue Aug 23, 2021 · 5 comments · Fixed by #34264
Closed

Scripts: Filename changes to main.js when ouput-path parameter is added #34239

Soean opened this issue Aug 23, 2021 · 5 comments · Fixed by #34264
Labels
[Tool] WP Scripts /packages/scripts [Type] Bug An existing feature does not function as intended

Comments

@Soean
Copy link
Member

Soean commented Aug 23, 2021

Description

Related to webpack v5 migration: #33818.

If I add a output-path, the build files are renamed to main.js and main.asset.php. Without the parameter, the filename doesn't change.

Step-by-step reproduction instructions

wp-scripts build --entry ./src/index.js --output-path=custom

Environment info

  • WP Scripts 18
@Soean Soean added [Type] Bug An existing feature does not function as intended [Tool] WP Scripts /packages/scripts labels Aug 23, 2021
@Soean Soean changed the title Filename changes to main.js when ouput-path parameter is added Scripts: Filename changes to main.js when ouput-path parameter is added Aug 23, 2021
@gziolo
Copy link
Member

gziolo commented Aug 24, 2021

There is a similar issue reported related to how entry points are handled with webpack 5: #34236.

It looks like the following doesn't work anymore with the latest major version of @wordpress/scripts:

npx wp-scripts build ./src/frontend/index.js

@walbo
Copy link
Member

walbo commented Aug 24, 2021

The default entry name in webpack is main, and in the config filename is set to [name].js. You can overwrite the filename config by adding --output-filename.

wp-scripts build --entry ./src/index.js --output-path=custom --output-filename=index.js

@gziolo
Copy link
Member

gziolo commented Aug 25, 2021

@walbo thank you for sharing the example. It partially works with the default webpack config, in the context of blocks:

Screen Shot 2021-08-25 at 10 44 31

While it applies changes to the output folder and the JavaScript filename, it doesn't get propagated to CSS chunks.

See my related comment for more details: #34264 (comment).

@gziolo
Copy link
Member

gziolo commented Sep 8, 2021

It looks like #34264 will fix this issue.

@gziolo
Copy link
Member

gziolo commented Sep 9, 2021

There is @wordpress/scripts v18.0.1 available with the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Tool] WP Scripts /packages/scripts [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants