开发 loader
markdown-loader
const marked = require("marked")
module.exports = source => {
const html = marked(source)
return `module.exports = ${JSON.stringify(html)}`
}
loader 专注实现资源模块之间的加载
plugin 去解决项目中除了资源加载为其他自动化工作
webpack 插件机制介绍
- e.g 清除 dist 目录
- e.g 拷贝静态文件到输出目录
- e.g 压缩代码
webpack 常见插件
- 自动清理输出目录的插件
- 自动生成使用 bundle.js 的 html 插件 html-webpack-plugin