Skip to content

fix(index.js): Support function loaders #116

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

Conversation

sebastianseilund
Copy link

updateWebpackConfig previously expected use entries to be strings or arrays, and would throw needle.includes is not a function errors when given a function that returns a loader object.

I ran into this while using react-svg-loader:

{
  test: /\.svg$/,
  use: [
    ({resource}) => {
      const prefix = `svg${stringHash(
        path.relative(webDir, resource)
      )}`
      return {
        loader: 'react-svg-loader',
        options: {
          svgo: {
            plugins: [
              {
                cleanupIDs: {
                  prefix
                }
              }
            ]
          }
        }
      }
    }
  ]
}

It uses a function to return a loader object per resource, so that svgo can be instructed to give svgs unique ids.

ScriptedAlchemy and others added 2 commits October 8, 2018 15:01
updateWebpackConfig previously expected `use` entries to be strings or arrays, and would throw `needle.includes is not a function` errors when given a function that returns a loader object.
@ScriptedAlchemy ScriptedAlchemy changed the base branch from master to css-module-oneof-hmr October 9, 2018 17:04
@ScriptedAlchemy ScriptedAlchemy merged commit 7d591ac into faceyspacey:css-module-oneof-hmr Oct 9, 2018
@ScriptedAlchemy
Copy link
Collaborator

published as 3.2.1-alpha.1

ScriptedAlchemy added a commit that referenced this pull request Oct 23, 2018
* fix: Fixed HMR issue when oneOf is used

When using oneOf, HRM is never activated. This patch improved the lookup system used for determining
if CSS can and should be reloaded. There have been some other tweaks for css modules and HMR

fix #98,#80

* fix: Applying rollback fixes to updateWebpackConfig, search loader and use object keys

* fix: Adding back exported out hot loader

* docs(readme): Adding example of manual hotloader implementation

In the event users cannot get it to work, theres an example in the docs to reference

* fix: handle functions as loaders

Do not break when searching through `use` or `loader` that is a function

* fix(index.js): Support function loaders (#116)

* docs(readme): Tone of Voice clairification on what hot:true does (#113)

* fix(index.js): Support function loaders

updateWebpackConfig previously expected `use` entries to be strings or arrays, and would throw `needle.includes is not a function` errors when given a function that returns a loader object.

* Update README.md

* test: Fixing function-loader tests

* Add reloadAll and cssModules to typings (#115)

* docs(readme): Tone of Voice clairification on what hot:true does (#113)

* Add reloadAll and cssModules to typings
@faceyspacey
Copy link
Owner

🎉 This PR is included in version 3.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

3 participants