问题描述
依赖版本:
"css-loader": "^4.3.0","style-loader": "^1.2.1","webpack": "^2.2.0-rc.0"
这是我的webpack.config.js文件-
const path = require('path');
const config = {
entry: './src/index.js',output: {
path: path.resolve(__dirname,'build'),filename: 'main.bundle.js'
},module: {
rules: [
{ use: 'babel-loader',test: /\.js$/ },{ use: ['style-loader','css-loader'],test: /\.css$/ }
]
}
}
............................................... ... 我遇到以下错误:
keywords if/then/else require v5 option
(node:15780) UnhandledPromiseRejectionWarning: TypeError: this.getResolve is not a function
at Object.loader (C:\Projects\webpack-test\node_modules\css-loader\dist\index.js:62:27)
解决方法
我认为您需要更新webpack
版本或降级css-loader
。可能您还需要对style-loader
做一些事情。
Css加载程序需要Webpack 4.27.0及更高版本。
"peerDependencies": {
"webpack": "^4.27.0 || ^5.0.0"
},