其它选项(Other Options)

These are the remaining configuration options supported by webpack.

Help Wanted: This page is still a work in progress. If you are familiar with any of the options for which the description or examples are incomplete, please create an issue and submit a PR at the docs repo!

amd

object

设置 require.amddefine.amd 的值:

amd: {
  jQuery: true
}

某些流行的模块是按照 AMD 规范编写的,最引人瞩目的 jQuery 版本在 1.7.0 到 1.9.1,如果 loader 提示它对页面包含的多个版本采取了特殊许可时,才会注册为 AMD 模块。

许可权限是具有「限制指定版本注册」或「支持有不同定义模块的不同沙盒」的能力。

此选项允许将模块查找的键(key)设置为真值(truthy value)。 发生这种情况时,webpack 中的 AMD 支持将忽略定义的名称。

bail

boolean

在第一个错误出现时抛出失败结果,而不是容忍它。默认情况下,当使用 HMR 时,webpack 会将在终端以及浏览器控制台中,以红色文字记录这些错误,但仍然继续进行打包。要启用它:

bail: true

这将迫使 webpack 退出其打包过程。

cache

boolean object

缓存生成的 webpack 模块和 chunk,来改善构建速度。缓存默认在观察模式(watch mode)启用。禁用缓存只需简单传入:

cache: false

如果传递一个对象,webpack 将使用这个对象进行缓存。保持对此对象的引用,将可以在 compiler 调用之间共享同一缓存:

let SharedCache = {};

export default {
  ...,
  cache: SharedCache
}

不要在不同选项的调用之间共享缓存。

?> Elaborate on the warning and example - calls with different configuration options?

loader

object

在 loader 上下文中暴露自定义值。

?> Add an example...

profile

boolean

捕获一个应用程序"配置文件",包括统计和提示,然后可以使用 Analyze 分析工具进行详细分析。

使用 StatsPlugin 可以更好地控制生成的配置文件。

recordsPath

Use this option to generate a JSON file containing webpack "records" -- pieces of data used to store module identifiers across multiple builds. You can use this file to track how modules change between builds. To generate one, simply specify a location:

recordsPath: path.join(__dirname, 'records.json')

Records are particularly useful if you have a complex setup that leverages Code Splitting. The data can be used to ensure the split bundles are achieving the caching behavior you need.

Note that although this file is generated by the compiler, you may still want to track it in source control to keep a history of how it has changed over time.

Setting recordsPath will essentially set recordsInputPath and recordsOutputPath to the same location. This is usually all that's necessary unless you decide to change the name of the file containing the records. See below for an example.

recordsInputPath

Specify the file from which to read the last set of records. This can be used to rename a records file. See the example below.

recordsOutputPath

Specify where the records should be written. The following example shows how you might use this option in combination with recordsInputPath to rename a records file:

recordsInputPath: path.join(__dirname, 'records.json'),
recordsOutputPath: path.join(__dirname, 'newRecords.json')

原文:https://webpack.js.org/configuration/other-options/

results matching ""

    No results matching ""