在问这个问题之前我搜索了SO,得到了相关文章: ReferenceError: resolve is not defined
但它不适合我的情况,因为我的webpack配置错误,我不知道为什么会遇到这个问题。
当我使用npm run build
时,我收到了以下错误:
/Users/ldsole/Desktop/my-project/web/wx_backup/webpack.base.config.js:51
use: ExtractTextPlugin.extract({
^
ReferenceError: resolve is not defined
at Object.<anonymous> (/Users/luowensheng/Desktop/my-project/web/wx_backup/webpack.base.config.js:51:40)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/luowensheng/Desktop/my-project/web/wx_backup/webpack.prod.config.js:5:27)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! wx_backup@1.0.0 build: `webpack --progress --hide-modules --config webpack.prod.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the wx_backup@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/lasdas/.npm/_logs/2018-04-08T05_51_10_773Z-debug.log
你看到了npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
,我不知道为什么会出错。
我的原因错误代码(webpack.base.config.js)如下:
{
test: /\.css$/,
use: ExtractTextPlugin.extract({ // there is the error line.
use: ['css-loader?minimize', 'autoprefixer-loader'],
fallback: 'style-loader'
})
},