webpack 大概

entry

output

loader:

  rules: [

    {test:匹配文件格式,  use: 使用的loader},

    {test:匹配文件格式,  use: 使用的loader},

    ...//loader的执行顺序是从下往上,rules中最后一个loader最先被执行

  ]  

plugin: 用于执行特定任务,如:打包优化,资源管理,注入环境变量等

mode:模式

管理输出:

  html-webpack-plugin:生成index.html

  clean-webpack-plugin:清除dist

开发环境:

   source-map:追溯错误来源文件(devtool: 'inline-source-map',

  自动编译:

    webpack-dev-server:加配置 devServer:{ contentBase: './dist' };在编译之后不会写入到任何输出文件。而是将 bundle 文件保留在内存中,然后将它们 serve 到 server 中,就好像它们是挂载在 server 根路径上的真实文件一样。

    webpack watch mode:webpack --watch,自动编译,不刷新浏览器

    webpack-dev-middleware




原文地址:https://www.cnblogs.com/laojun/p/10690743.html