From d4679d368d421873f11e7e188ea7b6edd52fd318 Mon Sep 17 00:00:00 2001 From: pplokijuhyg <1162963624@qq.com> Date: Mon, 2 Dec 2019 14:24:24 +0800 Subject: [PATCH] update --- webpack.md | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/webpack.md b/webpack.md index 149c19c..8158591 100644 --- a/webpack.md +++ b/webpack.md @@ -65,4 +65,23 @@ module.exports = config; ### 插件 loader可以作为转换某种类型的模块 插件可以做各式各样的工作? -引用插件 先require +引用插件 先require() +然后加入到plugis数组中 +``` +const HtmlWebpackPlugin = require('html-webpack-plugin'); // 通过 npm 安装 +const webpack = require('webpack'); // 用于访问内置插件 + +const config = { + module: { + rules: [ + { test: /\.txt$/, use: 'raw-loader' } + ] + }, + plugins: [ + new HtmlWebpackPlugin({template: './src/index.html'}) + ] +}; + +module.exports = config; +``` +