From ed728f66d330b913490e7cd51773fe46794095e6 Mon Sep 17 00:00:00 2001 From: shenjianZ Date: Fri, 26 Jul 2024 12:45:28 +0800 Subject: [PATCH] update --- 01/webpack.config.js | 7 +++++-- README.md | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/01/webpack.config.js b/01/webpack.config.js index 2cc6557..14fe46d 100644 --- a/01/webpack.config.js +++ b/01/webpack.config.js @@ -1,8 +1,11 @@ +const webpack = require('path') module.exports = { mode: "development", entry: './src/index.js', output: { - filename: 'bundle.js' - }, + filename: "bundle-main.js", // 默认值 + clean: true, + path: `${__dirname}/dist/dist` // 指定打包后的文件路径 + } } \ No newline at end of file diff --git a/README.md b/README.md index 71f67ac..8a1ef28 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,40 @@ # buiildToolStudy +**初始化项目** +```shell +npm init -y +``` +**安装webpack依赖(开发依赖)** +```shell +npm add -D webpack webpack-cli +``` +**打包项目** +```shell +npx webpack +``` + +### entery 入口文件 +**入口文件是webpack的起点,通过入口文件来找到项目中的所有依赖模块。** +```shell +module.exports = { + entry: './src/index.js', //默认值 + entry:"./hello/hello.js", // 修改默认值 + entry: ["./src/a.js", "./src/b.js"], // 多个入口文件 + entry: { + hello: "./src/a.js", + b: "./src/b.js" + } // 多个入口文件,使用对象形式 +} +``` +### output 出口文件 +**出口文件是webpack打包后输出的文件。** +```shell +module.exports = { + output: { + filename: "bundle.js", // 默认值 + clean: true, // 清除打包文件所在目录 + path: `${__dirname}/dist/dist` // 指定打包后的文件路径 + } +} +``` + \ No newline at end of file