css-loader: [2.0.0] ValidationError: CSS Loader Invalid Options - options should NOT have additional properties
- Operating System: Linux workstation 4.15.0-42-generic #45-Ubuntu SMP Thu Nov 15 19:32:57 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
- Node Version: 11.4.0
- NPM Version: 6.4.1
- webpack Version: latest 4.27.1
- css-loader Version: latest - 2.0.0
Expected Behavior
I can use the css-loader, I have not changed anything.
Actual Behavior
ERROR in ./node_modules/material-design-icons/iconfont/material-icons.css
Module build failed (from ./node_modules/css-loader/dist/cjs.js):
ModuleBuildError: Module build failed (from ./node_modules/css-loader/dist/cjs.js):
ValidationError: CSS Loader Invalid Options
options should NOT have additional properties
at validateOptions (/media/linux-nvme/home/patrikx3/Projects/patrikx3/corifeus/corifeus-web-material/node_modules/schema-utils/src/validateOptions.js:32:11)
at Object.loader (/media/linux-nvme/home/patrikx3/Projects/patrikx3/corifeus/corifeus-web-material/node_modules/css-loader/dist/index.js:44:28)
at runLoaders (/media/linux-nvme/home/patrikx3/Projects/patrikx3/corifeus/corifeus-web-material/node_modules/webpack/lib/NormalModule.js:301:20)
at /media/linux-nvme/home/patrikx3/Projects/patrikx3/corifeus/corifeus-web-material/node_modules/loader-runner/lib/LoaderRunner.js:364:11
at /media/linux-nvme/home/patrikx3/Projects/patrikx3/corifeus/corifeus-web-material/node_modules/loader-runner/lib/LoaderRunner.js:230:18
at runSyncOrAsync (/media/linux-nvme/home/patrikx3/Projects/patrikx3/corifeus/corifeus-web-material/node_modules/loader-runner/lib/LoaderRunner.js:143:3)
at iterateNormalLoaders (/media/linux-nvme/home/patrikx3/Projects/patrikx3/corifeus/corifeus-web-material/node_modules/loader-runner/lib/LoaderRunner.js:229:2)
at iterateNormalLoaders (/media/linux-nvme/home/patrikx3/Projects/patrikx3/corifeus/corifeus-web-material/node_modules/loader-runner/lib/LoaderRunner.js:218:10)
at /media/linux-nvme/home/patrikx3/Projects/patrikx3/corifeus/corifeus-web-material/node_modules/loader-runner/lib/LoaderRunner.js:233:3
at context.callback (/media/linux-nvme/home/patrikx3/Projects/patrikx3/corifeus/corifeus-web-material/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
at Object.render [as callback] (/media/linux-nvme/home/patrikx3/Projects/patrikx3/corifeus/corifeus-web-material/node_modules/sass-loader/lib/loader.js:76:9)
at Object.done [as callback] (/media/linux-nvme/home/patrikx3/Projects/patrikx3/corifeus/corifeus-web-material/node_modules/neo-async/async.js:8077:18)
at options.success (/media/linux-nvme/home/patrikx3/Projects/patrikx3/corifeus/corifeus-web-material/node_modules/node-sass/lib/index.js:308:32)
@ ./node_modules/material-design-icons/iconfont/material-icons.css
Code
// webpack.config.js
// If your bitchin' code blocks are over 20 lines, please paste a link to a gist
// (https://gist.github.com).
rules: [
{
test: /\.less$/,
use: [{
loader: 'style-loader' ,
}, {
loader: 'css-loader',
}, {
loader: 'less-loader',
}],
},
How Do We Reproduce?
It happens with css-loader 2.0.0
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 28
- Comments: 55 (21 by maintainers)
Commits related to this issue
- remove minimize option to 'css-loader' as it does not work in current version and causes error. Ref: https://github.com/webpack-contrib/css-loader/issues/863 — committed to vipranarayan14/vtranslit-web by vipranarayan14 5 years ago
- Updated dependencies — committed to Arne117/FU-User-Centered-Design-2019 by Arne117 5 years ago
Same issue here
And works fine if remove
minimize: true
.Coming across this issue again on 3.0.0
For me, it was
localIdentName
not being in the options schema. Is this a bug?localIdentName
is mentioned all over the README and docs.@p3x-robot
minimize
will be remove in1
version, you don’t need this option, just removeTo those needing help, just change the key <-> pair like what @eric-miffre mentioned. Here’s an example:
Before:
options: { modules: true, localIdentName: "[name]__[local]___[hash:base64:5]", },
After:
options: { modules: { localIdentName: "[name]__[local]___[hash:base64:5]", },
Notice how now you have a modules Object within the options Object. Just put all your previous key <-> value pairs within the modules Object and you’ll be good to go
Had the same issue, but it is indeed explained in the breaking changes section of the v3 changelog:
Which did solve it for me.
I have this issue on version 2.1.0, without any options at all. Had to downgrade to 1.0.1, which has solved the issue.
node_modules\css-loader\dist\options.json
.Confirmed working. In my case I changed it from
options: { localIdentName: '[hash:base64:5][path]-[local]' }
to
options: { modules: { localIdentName: '[hash:base64:5][path]-[local]' } }
in my webpack/babel config.
Hi @mhauens
For NextJS, please check this file: …\node_modules@zeit\next-css\css-loader-config.js
from row 70 to 82
const cssLoader = { loader: isServer ? ‘css-loader/locals’ : ‘css-loader’, options: Object.assign( {}, { modules: cssModules, //minimize: !dev, sourceMap: dev, importLoaders: loaders.length + (postcssLoader ? 1 : 0) }, cssLoaderOptions ) }
and comment or remove minimize option.
no issue in 1.0.1
Solved. Feel free to feedback.
@fpsqdb please don’t write
Same issue here
, it doesn’t help to solve issue, better create minimum reproducible test repo @wanliyunyan thanks, will be fixed in near futureUnfortunately, I had to downgrade to 1.0.1 from 2.1.1 because this issue is still impacting my builds.
Same problem with NextJs default config
There is not shit like ‘minimize:true’ in my config.
I don’t know why, but it’s okay to upgrade to the latest 3.2.0.
@p3x-robot remove this line https://github.com/patrikx3/gitlist/blob/master/webpack.config.js#L211 (minimize will be removed in
1
version)This worked for my VUE Js project:
Browse to the
/build/utils.js
file and in the object of thecss-loader
comment on the option that is marking you in the error. In my case I had to comment:minimize: process.env.NODE_ENV === 'production',
I have the same issue, I can confirm that in version 1.0.1 it works well