Skip to content

generateScopedName generates different hash than css-loader #48

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

Closed
yacodes opened this issue Nov 2, 2015 · 8 comments
Closed

generateScopedName generates different hash than css-loader #48

yacodes opened this issue Nov 2, 2015 · 8 comments

Comments

@yacodes
Copy link

yacodes commented Nov 2, 2015

Thanks, for making such cool feature as generateScopedName, but combining it with webpack's css-loader gives me different results.
Here is css-modules-require-hook config:

require('css-modules-require-hook')({
  generateScopedName: '[name]__[local]___[hash:base64:5]',
  mode: 'local'
});

And here is webpack's css-loader config:

{ 
      test: /\.css$/, 
      loader: 'style!css?modules&localIdentName=[name]__[local]___[hash:base64:5]!postcss',
      include: [
        path.resolve(__dirname, '..', 'app')
      ]
}

So hooks result is index__navitem___2ntrM, but css-loader's: index__navitem___1gRhv.

What can be wrong with config or is this hook's bug?

@yacodes yacodes changed the title generateScopedName provides different hash than css-loader generateScopedName generates different hash than css-loader Nov 2, 2015
@mightyaleksey
Copy link
Member

Can you check the version of the css-loader module you use? It should be v0.21.0 or higher.
Also context field in the webpack config can make a difference. You should provide rootDir to the require-hook if it isn't a current working directory (other then process.cwd()).

@yacodes
Copy link
Author

yacodes commented Nov 2, 2015

css-loader version is "^0.21.0", and so webpack's context and hook's rootDir are equivalent.

@mightyaleksey
Copy link
Member

Well, looks like a bug, I'll try to check it out. Thanks

@mightyaleksey mightyaleksey mentioned this issue Nov 2, 2015
Merged
@mightyaleksey
Copy link
Member

Yeah, you were right. I found it and solved the problem. Thanks again :)
Try out the new version please: 2.0.1

@yacodes
Copy link
Author

yacodes commented Nov 3, 2015

Now everything works like a charm, thanks a lot!

@yacodes yacodes closed this as completed Nov 3, 2015
@mightyaleksey
Copy link
Member

Thanks :)

@svnm
Copy link

svnm commented Feb 24, 2016

Thanks, I had the same issue, upgrading to version 0.21.0 of css-loader and using 3.0.0-beta of css-modules-require-hook as in your demo, now everything is working nicely.

@mightyaleksey
Copy link
Member

😄 👍

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

3 participants