Skip to content

css-loader options error #4357

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
Maorey opened this issue Jul 25, 2019 · 3 comments · Fixed by #4363
Closed

css-loader options error #4357

Maorey opened this issue Jul 25, 2019 · 3 comments · Fixed by #4363
Labels

Comments

@Maorey
Copy link

Maorey commented Jul 25, 2019

Version

4.0.0-beta.1

Reproduction link

https://github.com/vuejs/vue-cli

Environment info

css-loader 3.0.1

Steps to reproduce

  1. set css.loaderOptions.css.localIdentName get css-loader ValidationError
  2. set css.loaderOptions.css.modules.localIdentName get css-loader ValidationError too

What is expected?

correct css-loader option

What is actually happening?

wrong


@LinusBorg
Copy link
Member

Hi

Thanks for filing this issue! Could you please provide a small reproduction on jsfiddle.net or as a github reporsitory so we can debug this without trying to replicate this ourselves?`

That would be very helpful, thanks!

@LinusBorg LinusBorg added the needs reproduction This issue is missing a minimal runnable reproduction, provided by the author label Jul 25, 2019
@Maorey
Copy link
Author

Maorey commented Jul 25, 2019

It‘s quite simple,in css-loader 3.1.0, it's options like this:

{
  modules: {
    mode: 'local',
    localIdentName: '[path][name]__[local]--[hash:base64:5]',
    context: path.resolve(__dirname, 'src'),
    hashPrefix: 'my-custom-hash',
  },
  localsConvention: 'camelCaseOnly,
}

but in this line:

const { localIdentName = '[name]_[local]_[hash:base64:5]' } = loaderOptions.css || {}
Object.assign(cssLoaderOptions, {
  modules: {
    localIdentName,
  },
})

so, when pass:

{
  modules: {
    localIdentName: '[folder]-[name]-[local][emoji]',
  },
  localsConvention: 'camelCaseOnly,
}

get:

{
  modules: {
    localIdentName: '[name]_[local]_[hash:base64:5]',
  },
  localsConvention: 'camelCaseOnly,
}

That's not i wanted

pass:

{
  localIdentName: '[folder]-[name]-[local][emoji]',
  localsConvention: 'camelCaseOnly,
}

get:

{
  modules: {
    localIdentName: '[folder]-[name]-[local][emoji]',
  },
  localIdentName: '[folder]-[name]-[local][emoji]',
  localsConvention: 'camelCaseOnly,
}

That's will get a ValidationError

@haoqunjiang haoqunjiang added bug and removed needs reproduction This issue is missing a minimal runnable reproduction, provided by the author labels Jul 25, 2019
haoqunjiang added a commit to haoqunjiang/vue-cli that referenced this issue Jul 26, 2019
@Maorey
Copy link
Author

Maorey commented Jul 27, 2019

And, how about this option: css.modules?

By default, only files that ends in *.module.[ext] are treated as CSS modules. Setting this to true will allow you to drop .module in the filenames and treat all *.(css|scss|sass|less|styl(us)?) files as CSS modules.

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 a pull request may close this issue.

3 participants