webpack採坑

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(生產模式)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章