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

output.filename as function doesn't work #39

Closed
ndesorden opened this issue Nov 28, 2018 · 2 comments · Fixed by #42
Closed

output.filename as function doesn't work #39

ndesorden opened this issue Nov 28, 2018 · 2 comments · Fixed by #42

Comments

@ndesorden
Copy link

With latest webpack (4.26.1) using options.filename with a function throws error when adding GitRevisionPlugin to plugins array

return {
        entry: {
            app: `./${SRCFOLDER}/entrypoints/main.js`
        },
        output: {
            filename: () => 'test.js' 
            // with example function from docs same error
            filename: (chunkData) => {
                 return chunkData.chunk.name === 'main' ? '[name].js': '[name]/[name].js';
           },
        },
 ...

        plugins: [
            new GitRevisionPlugin({
                versionCommand: 'describe --always --tags --abbrev=0'
            }),

Console output:

ERROR in chunk app [entry]
() => 'test.js'
path.replace is not a function
error Command failed with exit code 2.

Other relevant information:
webpack version: 4.26.1
Node.js version: 8.11.2
Operating System: windows 10
Additional tools:

@ndesorden
Copy link
Author

ndesorden commented Nov 30, 2018

Something like this fix the issue:

    compilation.mainTemplate.hooks.assetPath.tap('asset-path', (filename, chunkData) => {
      return (typeof filename === 'function'
        ? filename(chunkData)
        : filename).replace(replacePattern, data);
    })

njbmartin pushed a commit to njbmartin/git-revision-webpack-plugin that referenced this issue Jun 12, 2019
@pmeinhardt
Copy link

I ran into the same issue after upgrading mini-css-extract-plugin from 0.5.0 to 0.8.0.
Thanks for having taken the time to fix this issue already @njbmartin 🙇

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

Successfully merging a pull request may close this issue.

2 participants