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

lessPlugins ignored, potential fix #161

Closed
bazineta opened this issue Mar 12, 2017 · 7 comments · Fixed by m1guelpf/miguelpiedrafita.com#14
Closed

lessPlugins ignored, potential fix #161

bazineta opened this issue Mar 12, 2017 · 7 comments · Fixed by m1guelpf/miguelpiedrafita.com#14

Comments

@bazineta
Copy link

bazineta commented Mar 12, 2017

Original discussion on this can be found toward the end of #115.

In 3.0.0, lessPlugins option as documented in the README doesn't appear to actually do anything.

If I instead specify less plugins in plugins, the cloneDeep() call in the loader's options processing will wipe the install function from each plugin, and a plugin.install is not a function will be emitted during processing.

What seems to work, assuming that lessPlugins is the desired approach, is adding this:

if (options.lessPlugins) {
    options.plugins.push.apply(options.plugins, loaderUtils.getOptions(this).lessPlugins);
}

immediately after the line:

options.plugins.push(webpackPlugin);

In the loader.

I'd guess that cloneDeep() might not actually be what's desired here, but this approach matches the README.

@bazineta bazineta changed the title lessPlugins ignored lessPlugins ignored, potential fix Mar 12, 2017
@bazineta
Copy link
Author

@jhnns If this makes sense, or if I'm off base here but could address this some other way, please let me know -- quite happy to submit a PR if this is appropriate.

@jhnns
Copy link
Member

jhnns commented Mar 14, 2017

Thx, I'll take a look in the next days. The documentation might be out of date, have to check that.

@kfeinUI
Copy link

kfeinUI commented Mar 14, 2017

Confirmed. The suggested fix seems to do the trick at least in fixing the error. Not sure the plugins are fed the ~ module paths correctly though.

@jhnns
Copy link
Member

jhnns commented Mar 20, 2017

This should be fixed with less-loader 4. We have a test for it.

We're still using cloneDeep(), so I'm not sure what has changed. But the test is running...

@jhnns jhnns closed this as completed Mar 20, 2017
@bazineta
Copy link
Author

@jhnns Well, I'd love to test it out, but at present 4.0.0 has a 'dist/cjs.js' in the package.json, which doesn't exist, so it won't run.

@bazineta
Copy link
Author

@jhnns However, assuming something along the lines of index.js is what's needed there, it still won't run, and it fails with the same 'install isn't a function' error. I have no idea how your test case could be running; cloneDeep() will destroy any function present, period.

@bazineta
Copy link
Author

@jhnns The same fix works in this case; in getOptions.js:

options.filename = loaderContext.resource;

  if (options.lessPlugins) {
      options.plugins.push.apply(options.plugins, loaderUtils.getOptions(loaderContext).lessPlugins);
  }

Note that I've used the old 'lessPlugins' key here, as cloneDeep() will have damaged what's in 'plugins' beyond the ability to easily use at this point.

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.

3 participants