1,安装webpack4X以上版本,会提示安装webpack-cli(请注意:webpack-cli要和webpack安装在同一目录里)
参考:https://blog.csdn.net/zengibm/article/details/79914144
提示: 这里提示安装 webpack-cli// 是因为到了webpack4, webpack 已经将 webpack 命令行相关的内容都迁移到 webpack-cli,所以除了 webpack 外,我们还需要安装 webpack-cli
2,
参考:https://blog.csdn.net/cominglately/article/details/80555210
提示: 参考官方文档 https://vue-loader.vuejs.org/migrating.html#a-plugin-is-now-required
Vue-loader在15.*之后的版本都是 vue-loader的使用都是需要伴生 VueLoaderPlugin的,
解决:
const VueLoaderPlugin = require('vue-loader/lib/plugin');
module.exports = {
devtool: "sourcemap", entry: './js/entry.js', // 入口文件
output: {
filename: 'bundle.js' // 打包出来的wenjian
},
plugins: [
// make sure to include the plugin for the magic
new VueLoaderPlugin()
],
module : { ... }
}
3,
参考: https://www.imooc.com/qadetail/260563?t=421161
解决: 添加依赖包
rules: [
{test: /\.css$/,use: ["vue-style-loader", "css-loader"] }
]
4,
参考:https://blog.csdn.net/wscfan/article/details/81940759
提示: 打包成功 但是还有一个警告 WARNING in configuration The ‘mode’ option has not been set. Set ‘mode’ option to ‘development’ or ‘production’ to enable defaults for this environment.是因为使用webpack没有指定mode为 development(开发模式)或者为production(生产模式)