Webpack4系列教程(一) 基礎入門

寫在前面

在這篇博客中,我將會介紹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:模式
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章