寫在前面
在這篇博客中,我將會介紹webpack4的基本配置
安裝與配置
首先我們要安裝相關環境
cnpm i -D webpack webpack-cli
目錄結構如下
webpack.config.js
是默認的配置文件,我們寫下最基本的配置
module.exports = {
entry: {
index: './src/index.js'
},
output: {
path: path.resolve('dist'),
filename: '[name].bundle.js'
},
plugins: [],
module: {
rules: []
},
mode: 'development'
}
這五個配置中:
- entry:打包入口
- output:打包出口
- plugins: 插件配置
- module/rules:loader配置
- mode:模式