报错问题:
webpack 打包出现 TypeError: this.getResolve is not a function
环境:
- nodejs 12.13.0
- npm 6.12.0
- webpack 4.41.2
webpack 配置如下
var webpack = require('webpack')
var path = require('path')
module.exports = {
entry: [
'./app.js'
],
output: {
path: path.resolve(__dirname, './build'),
filename: 'bundle.js'
},
module: {
rules: [
{
test: /.css$/,
use: [
{loader: 'style-loader'},
{loader: 'css-loader'}
]
},
{
test: /.scss$/,
use: [
{loader: 'style-loader'},
{loader: 'css-loader'},
{loader: 'sass-loader'}
]
},
{
test: /.(png|jpg)$/,
use: [
{loader: 'url-loader',
options: {
limit: 8192
}
}
]
}
]
}
}
原因:
出现该问题的情况是 sass-loader 版本过高, 用 ^8.0.0 版本出现该问题
解决:
先卸载当前 sass-loader 版本,后安装 "^7.3.1" 的 sass-loader 版本后正常使用。