008-ant design roadhogrc 打包

1、概述

1.一、官方地址以及说明

  因为 Ant Design Pro 底层使用的 roadhog 工具,已经将复杂的流程封装完毕,对于大部分场景,构建打包文件只须要一个命令 roadhog build,构建打包成功以后,会在根目录生成 dist 文件夹,里面就是构建打包好的文件,一般是 ***.js***.cssindex.html 等静态文件。css

  意思是使用默认package.json中的build便可html

1.二、定制化打包

  经过设置.webpackrc.js实现定制化打包。内部参数设置webpack

开发线上区分git

"env": {
  // 开发环境
  "development": {
    "extraBabelPlugins": [
      "dva-hmr",
    ]
  },
  // build 时的生产环境
  "production": {
    "extraBabelPlugins": [
      "transform-runtime",
      "transform-decorators-legacy",
      ["import", { "libraryName": "antd", "style": true }]
    ]
  }
},
View Code

1.三、针对文件目录定制化.webpackrc.js

其实主要是设置.webpackrc.jsgithub

官方地址:https://github.com/sorrycc/roadhog  web

中文地址:https://github.com/sorrycc/roadhog/blob/master/README_zh-cn.md
json

经常使用配置:数组

  publicPath

    配置 webpack 的 output.publicPath 属性。antd

  outputPath

    配置 webpack 的?output.path?属性。ide

  copy

    定义须要单纯作复制的文件列表,格式为数组,项的格式参考 copy-webpack-plugin 的配置。

    好比:

"copy": [
  {    "from": "",    "to": ""  }
]

1.四、探究

  查看可知,pro ant design 打包→roadhog 打包→webpack打包

  webpack地址:https://webpack.js.org/configuration/

  中文地址:https://webpack.docschina.org/concepts/

相关文章
相关标签/搜索