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

Plugins still broken #181

Closed
bazineta opened this issue Mar 21, 2017 · 13 comments
Closed

Plugins still broken #181

bazineta opened this issue Mar 21, 2017 · 13 comments

Comments

@bazineta
Copy link

See #161.

@jhnns
Copy link
Member

jhnns commented Mar 21, 2017

Could you create a small test repository with webpack 2 and less-loader 4.x that demonstrates that the less plugin is not installed?

@bazineta
Copy link
Author

bazineta commented Mar 21, 2017

Sure. Since the test files are so small, if it's all the same to you I'll just attach them here as a zip file.

test.less.zip

Extract to a directory of your choice, npm install, then npm start.

Should result in the 'Plugin.install is not a function' error.

I've used what I believe to be the two most commonly used less plugins for the test case.

@illinar
Copy link

illinar commented Mar 21, 2017

Patching package.json entry (see 918bfe9) seems to resolve the problem.

@bazineta
Copy link
Author

@illinar Oleg, I think you're referring to the 4.0.0 issue of the package.json referencing a non-existing entry point -- that was corrected in 4.0.1. This issue is in regard to Less plugins not being usable.

@jhnns
Copy link
Member

jhnns commented Mar 21, 2017

@bazineta thx. clone-deep copies functions, but apparently no properties on the prototype chain (didn't expect this). Since Less plugins are instances of functions/classes, all methods are usually on the prototype instead of the actual instance. That's why our test case is working and actual Less plugins are not. Need to fix that. Thanks for providing a test case.

jhnns added a commit that referenced this issue Mar 21, 2017
clone-deep does not clone properties from the prototype chain, see #181 (comment)
jhnns added a commit to webpack/loader-utils that referenced this issue Mar 21, 2017
Replace clone-deep with clone since clone-deep does not copy properties from the prototype chain. This can be a problem with plugin instances, see webpack-contrib/less-loader#181 (comment)
@jhnns
Copy link
Member

jhnns commented Mar 21, 2017

Should be fixed with 4.0.2

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

LGTM. Thanks!

@sengfan
Copy link

sengfan commented Mar 22, 2017

Still has the error, Did I make something wrong?
Can anybody help?
Thanks
qq 20170322002334
image
image

@sengfan
Copy link

sengfan commented Mar 22, 2017

it seems it's not compatible with style-loader and to-string-loader?
It works with prod mode, but in dev mode, which fallback to "style-loader", it will show Plugin.install is not a function
{ test: /\.less$/, use: ExtractTextPlugin.extract({ fallback: 'style-loader', use: [ 'css-loader', { loader: 'less-loader', options: { plugins: [ lessPluginAutoPrefix, lessPluginCleanCSS ] } } ] }), include: [helpers.root('src/assets/less')] }

Did I miss something?

@jhnns
Copy link
Member

jhnns commented Mar 22, 2017

@sengfan please provide a small example repository. This makes tracking down the problem so much easier for me.

@robgietema
Copy link

@jhnns I have the same issue as @sengfan , here's my repo where it occurs: https://github.com/plone/plone-react/tree/semantic-ui

@MarkJPerry
Copy link

I have an issue where the Plugins are not being run at all. I am using semantic-ui and need to re-write the import statements using less-plugin-rewrite-import and it never runs the plugin code at all.

@riarheos
Copy link

riarheos commented Nov 6, 2017

I also stumbled upon this problem and found a workaround (but cannot find a good solution though).

The problem comes from including plain css from the less-file with any plugin enabled. Replacing
@import "./reset.css";
with
@import "./reset.less";
worked for me. Hope this somehow helps with the error tracking.

The reproducible small-repo is attached.
less-loader-bug.zip

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

No branches or pull requests

7 participants