请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

webpack升级过程中localIdentName配置报错

ERROR in ./client/layout/header.vue (./node_modules/css-loader/dist/cjs.js?{“sourceMap”:true,“localIdentName”:"[path]-[name]-[hash:base64:5]",“importLoaders”:1,“modules”:true,“localsConvention”:“camelCase”}!./node_modules/vue-loader/lib/style-compiler?{“optionsId”:“0”,“vue”:true,“scoped”:false,“sourceMap”:true}!./node_modules/stylus-loader!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./client/layout/header.vue)
Module build failed (from ./node_modules/css-loader/dist/cjs.js):
ValidationError: Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema.

  • options has an unknown property ‘localIdentName’. These properties are valid:
    object { url?, import?, modules?, sourceMap?, importLoaders?, localsConvention?, onlyLocals?, esModule? }
    at validate (F:\VScode\vue-ssr-problem\node_modules\schema-utils\dist\validate.js:88:11)
    at Object.loader (F:\VScode\vue-ssr-problem\node_modules\css-loader\dist\index.js:36:28)
    @ ./client/layout/header.vue (./node_modules/vue-loader/node_modules/vue-style-loader!./node_modules/css-loader/dist/cjs.js?{“sourceMap”:true,“localIdentName”:"[path]-[name]-[hash:base64:5]",“importLoaders”:1,“modules”:true,“localsConvention”:“camelCase”}!./node_modules/vue-loader/lib/style-compiler?{“optionsId”:“0”,“vue”:true,“scoped”:false,“sourceMap”:true}!./node_modules/stylus-loader!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./client/layout/header.vue) 4:14-464 14:3-18:5 15:22-472
    @ ./client/layout/header.vue
    @ ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./client/app.vue
    @ ./client/app.vue
    @ ./client/create-app.js
    @ ./client/client-entry.js图片描述

正在回答 回答被采纳积分+3

3回答

qq_钟离紫灵_0 2021-03-11 18:12:16

css rules里面

// modules: true,
// localIdentName: '[local]_[hash:base64:8]'

改成

modules: {
 auto: true,
 localIdentName: '[path][name]__[local]--[hash:base64:5]',
}

0 回复 有任何疑惑可以回复我~
慕雪1162788 2020-05-29 14:45:34

+1,搞了好久依然无法解决这个报错

0 回复 有任何疑惑可以回复我~
  • Jokcy #1
    不是跟新,如果你要跟课程一样的配置方法,那么建议降级到上一个大版本,如果你要用最新版,就跟着文档的方法配置
    回复 有任何疑惑可以回复我~ 2020-06-01 21:18:00
Jokcy 2020-05-20 20:55:43

新版的css-loader,不支持localIdentName这个配置,报错信息里面写的很明白了,可以看一下最新的css-loader

0 回复 有任何疑惑可以回复我~
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信