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

帕尼尼0_0發表於2018-12-21

寫在前面

在這篇部落格中,我將會介紹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:模式

相關文章