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

Allow the output filename to be a function #1408

Closed
1 of 2 tasks
berthertogen opened this issue May 14, 2018 · 4 comments · Fixed by #1409
Closed
1 of 2 tasks

Allow the output filename to be a function #1408

berthertogen opened this issue May 14, 2018 · 4 comments · Fixed by #1409

Comments

@berthertogen
Copy link
Contributor

berthertogen commented May 14, 2018

  • Operating System: Win 10
  • Node Version: 9.7.1
  • NPM Version: 5.6.0
  • webpack Version: 4.7.0
  • webpack-dev-server Version: 3.1.4
  • This is a bug
  • This is a modification request

Code

  // webpack.config.js
entry: {
    vendors: './vendors.js',
    bundle: './bundle.js',
    bundlepreview: './bundle.preview.js',
},
output: {
    filename: (data) => data.chunk.name === "bundlepreview" ? '[name].js' : '[name].[chunkhash].js',
    path: buildPath
},

Expected Behavior

webpack-dev-server command starts the server and creates a bundlepreview.js without the chunkhash

Actual Behavior

webpack-dev-server command fails with the message:

× 「wds」: Invalid configuration object. webpack-dev-server has been initialised using a configuration object that does not match the API schema.
- configuration.filename should be one of these:
   RegExp | string
   The filename that needs to be requested in order to trigger a recompile (only in lazy mode).
   Details:
    * configuration.filename should be an instance of RegExp.
    * configuration.filename should be a string.

For Bugs; How can we reproduce the behavior?

For Features; What is the motivation and/or use-case for the feature?

In optionsSchema.json allow filename to be a function:

"filename": {
      "description": "The filename that needs to be requested in order to trigger a recompile (only in lazy mode).",
      "anyOf": [
        {
          "instanceof": "RegExp"
        },
        {
          "type": "string"
        },
        {
          "instanceof": "Function"
        }
      ]
    },
@berthertogen berthertogen changed the title Modification: Allow the output filename to be a function modification: Allow the output filename to be a function May 14, 2018
@alexander-akait
Copy link
Member

Please note that webpack-dev-server is presently in a maintenance-only mode and will not be accepting any additional features in the near term. Most new feature requests can be accomplished with Express middleware; please look into using the before and after hooks in the documentation.

Use webpack-serve for a fast alternative. Use webpack-dev-server if you need to test on old browsers.

From https://github.com/webpack/webpack-dev-server#project-in-maintenance

@stoykostanchev
Copy link

Could you reopen this, now that webpack-dev-server is maintained again?

@alexander-akait
Copy link
Member

@stoykostanchev 👍 PR welcome

@michael-ciniawsky michael-ciniawsky changed the title modification: Allow the output filename to be a function Allow the output filename to be a function Aug 26, 2018
@michael-ciniawsky
Copy link
Member

#1409

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants