webpack升级过程中localIdentName配置报错

来源:1-6 (如果您初学,建议您先跟着课程版本走,项目完成后再升级)补充Webpack4.29升级(2)

chenG丨Yu

2020-05-15

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回答

qq_钟离紫灵_0

2021-03-11

css rules里面

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

改成

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

0
0

慕雪1162788

2020-05-29

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

0
1
Jokcy
不是跟新,如果你要跟课程一样的配置方法,那么建议降级到上一个大版本,如果你要用最新版,就跟着文档的方法配置
2020-06-01
共1条回复

Jokcy

2020-05-20

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

0
2
安静的小y
回复
慕雪1162788
2.1.0
2020-08-26
共2条回复

Vue核心技术 Vue+Vue-Router+Vuex+SSR实战精讲

深入讲解Vue核心技术,展示Vue应用开发中的各种问题和解决方案

3168 学习 · 853 问题

查看课程