Skip to content

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

Closed

Description

@Soean

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

Activity

  1. added
    [Type] Bug
    [Tool] WP Scripts
    on Aug 23, 2021
  2. 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[/+] on Aug 23, 2021
  3. gziolo commented on Aug 24, 2021

    @gziolo
    Member

    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
  4. walbo commented on Aug 24, 2021

    @walbo
    Member

    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
    
  5. gziolo commented on Aug 25, 2021

    @gziolo
    Member

    @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).

  6. gziolo commented on Sep 8, 2021

    @gziolo
    Member

    It looks like #34264 will fix this issue.

  7. gziolo commented on Sep 9, 2021

    @gziolo
    Member

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Tool] WP Scripts[Type] Bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions