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; +``` +