-
Notifications
You must be signed in to change notification settings - Fork 0
cli.cn
$ npm install webpack -g
The webpack
command is now available globally.
现在webpack
命令全局可用
webpack <entry> <output>
Pass a file or a request string. You can pass multiple entries (every entry is loaded on startup).
传入一个文件或请求字符串。你可以传入多个入口文件(每个入口文件会在启动时加载)
If you pass a pair in the form <name>=<request>
you can create an additional entry point.
如果你传入形如<name>=<request>
的一对值,你可以传入一个额外的入口点。
It will be mapped to the configuration option entry
.
它将被映射到配置选项entry
。
Pass a path to a file.
传入目标文件路径
It will be mapped to the configuration options output.path
and output.filename
.
它将被映射到配置选项output.path
和output.filename
Many configuration options are mapped from CLI options. I. e. --debug
maps to debug: true
, or --output-library-target
to output.libraryTarget
.
许多配置选项从CLI选项映射而来。例如,--debug
映射到debug: true
,或--output-library-target
映射为output.libraryTarget
You will see a list of all options if you don't pass any options.
如果你不传递任何选项,你会看到所有选项的列表。
某些插件被映射到CLI选项。例如,--define <string> = <string>
映射到DefinePlugin
。
Some plugins are mapped to CLI options. I. e. --define <string>=<string>
maps to the DefinePlugin
.
You will see a list of all options if you don't pass any options.
如果你不传递任何选项,你会看到所有选项的列表。
Equals to --debug
--devtool source-map
--output-pathinfo
等价于 --debug
--devtool source-map
--output-pathinfo
Equals to --optimize-minimize
--optimize-occurence-order
等价于 --optimize-minimize
--optimize-occurence-order
Watches all dependencies and recompile on change. 监视所有依赖模块,出现变化时重新编译
Specifies a different configuration file to pick up. Use this if you want to specify something different than webpack.config.js
, which is the default.
指定另外一个配置文件来运行。如果你想使用不同于默认名为webpack.config.js
的配置文件,你可以使用这选项。
Display a compilation progress to stderr.
显示编译进度至标准错误流。
Write JSON to stdout instead of a human readable format. 输出JSON格式的数据到标准输出流,而不是人类可读格式
Hint: Try to put the result into the analyse tool. 提示:可以试试把结果导入分析工具
Disable colors to display the statistics. 显示统计信息时禁用颜色。
Sort the modules/chunks/assets list by a column. 按列分别排序 modules/chunks/assets
Display the separation of the modules into chunks. 显示模块到打包块的分离
Show more information about the reasons why a module is included. 显示有关为什么一个模块被引入的详细信息
Show more information about the errors. I. e. this shows which paths are tried while resolving a module. 显示有关错误的详细信息。例如,这个说明在解析模块尝试了哪些路径。
Show hidden modules. Modules are hidden from output by default when they live inside directories called ["node_modules", "bower_components", "jam", "components"]
显示隐藏的模块。当模块位于["node_modules", "bower_components", "jam", "components"]
,输出时默认被隐藏
Exclude modules in the output. 在输出信息中去除某些模块
If you wish to have a more in-depth idea of what is taking how long, you can use the --profile
switch. This will cause WebPack to display more detailed timing information. Combine this with the switches above to get a very detailed message and information set, which will contain the timings of your modules.
如果你想深入了解每个步骤所用时长,你可以使用--profile
开关。这会触发webpack显示更详细的时序信息。结合上述的开关选项来得到非常详细的消息和信息集,其中会包含你的模块的时序信息。
-
factory
: The time it took to build the module information. -
building
: The time that was spent building the module (loaders, for example). -
dependencies
: The time that was spent gathering and connecting the dependencies. -
factory
: 构建模块信息所花的时间. -
building
: 构建模块花费的时间 (例如loaders). -
dependencies
: 收集和关联依赖模块的耗时.
###其他配置选项
When using the CLI it's possible to have the following options in the configuration file. They're passed in other ways when using the node.js API.
当使用CLI时,它可能具有配置文件中的下列选项。当使用node.js API时,会使用其他方式传入配置。
Enter watch mode, which rebuilds on file change.
进入监听模式,文件更改重新构建。
Delay the rebuild after the first change. Value is time in ms.
延迟检测到第一个文件更改信号后重新构建的发生时间。值以ms为单位
Default: 300
true
: use polling
true
: 使用轮询策略
number: use polling with specified interval
number: 轮询的指定时间间隔
Default:
undefined
Display options. See node.js API Stats.toString()
for more details.
显示选项。参见node.js API Stats.toString()
了解更多详情。