在自行配置webpack.config.js的时候出现很多的问题,踩过的坑越多,就记得越牢;

1. configguration.output.path:The provided value './build' is not an absolute path 

或者ReferenceError: _dirname is not defined

解决方法:配置path的时候需要用到的是绝对路径,因此可以引入node中自带的path来解决;

注意:__dirname是两个下滑线

 const path = require('path')
 output:{
        path:path.join(__dirname,'build'),//将路径进行拼接,显示的就是c://...之类的
        filename:'app.js'
    }

2. No configuration file found and no output filename configured via CLI option.

A configuration file could be named 'webpack.config.js' in the current directory.
Use --help to display the CLI options. 

错误原因: 在webpack.config.js中config没有暴露

3.

 

posted on 2018-01-13 22:06  Anby-PBH  阅读(494)  评论(0编辑  收藏  举报