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

fixed buildExcludes options not working #333

Merged
merged 1 commit into from
Mar 11, 2022

Conversation

ihavecoke
Copy link
Contributor

Fixed buildExcludes option not working at all

Here are some source code,

next-pwa

exclude: [
  ({ asset, compilation }) => {
    if (asset.name.match(/^(build-manifest\.json|react-loadable-manifest\.json|server\/middleware-manifest\.json|server\/middleware-runtime\.js|_middleware\.js|server\/pages\/_middleware\.js)$/)) {
      return true
    }
    .....
    return false
  },
  ...buildExcludes
]

exclude options first element is function type, when pass to workbox-webpack-plugin apply checkCondition function. it always match first if condition. so that your buildExcludes with some string strategy or regex strategy will not match at all. on the other words buildExcludes not effect.

below is workbox-webpack-plugin source code

function checkConditions(asset, compilation, conditions = []) {
    for (const condition of conditions) {
        if (typeof condition === 'function') {
            return condition({ asset, compilation });
            //return compilation !== null;
        }
        else {
            if (webpack_1.ModuleFilenameHelpers.matchPart(asset.name, condition)) {
                return true;
            }
        }
    }
    // We'll only get here if none of the conditions applied.
    return false;
}

@ihavecoke ihavecoke changed the title fixed buildExcludes strategy bug fixed buildExcludes options not working Mar 10, 2022
@garganurag89
Copy link

garganurag89 commented Mar 10, 2022

Hi @shadowwalker ,
Thanks for this fix. Can you please release this I need this in my project to exclude the source maps file?

Copy link
Owner

@shadowwalker shadowwalker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is either a bug for while or workbox changed some of the code on their end.

@shadowwalker shadowwalker merged commit 7041bc6 into shadowwalker:master Mar 11, 2022
@garganurag89
Copy link

Hi @shadowwalker ,
, is missing after buildExcludes in line number 197. Kindly add that as well.

@shadowwalker
Copy link
Owner

Yeah, I fixed locally.

@shadowwalker
Copy link
Owner

Published 5.4.6

@garganurag89
Copy link

Thanks a lot

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 this pull request may close these issues.

None yet

3 participants