1.2 Splitting the Configuration

來源:http://survivejs.com/webpack/developing-with-webpack/splitting-configuration/

當專案越來越大,你就要開始去想要怎麼管理 Webpack configuration。 最好是按照環境不同把它拆分出來。

有幾種方式可以做到:

  • Maintain configuration in multiple files and point Webpack to each through --config parameter. Share configuration through module imports. You can see this approach in action at webpack/react-starter.
  • Push configuration to a library which you then consume. Example: HenrikJoreteg/hjs-webpack.
  • Maintain configuration within a single file and branch there. If we trigger a script through npm (i.e., npm run test), npm sets this information in an environment variable. We can match against it and return the configuration we want.

作者比較偏好最後一種做法,為此他也開發一個 webpack-merge 工具來達成目的。

results matching ""

    No results matching ""