The last one we will webpack
entrance entry
, that since there is the entrance, there will be a corresponding export. So in this section we will webpack
about the exit output
.
output
attribute is used to specify webpack
how to output, and where the output it creates bundles
, and how to name files. Basically the entire application structure will be compiled into the folder of the specified output path. We can configure these processes output
field in the configuration file.
output configuration
output
is a object
object, which contains a series of configuration items, of which the more important ones are filename
and path
.
output.filename
: Configure the name of the output file, and specify astring
type 060ed480eac2aa. If there is only one output file, it can be written as static and unchanging.output.path
: The configuration output file is stored in a local directory, which is an absolute path of typestring
The absolute path is usually obtained through thepath
In the webpack.config.js
configuration file, a entry
corresponds to a output
.
Example:
For example, the following code:
module.exports = {
entry:'./index.js',
output:{
path:__dirname,
filename:'./bundle.js'
}
}
The code specifies an entry file index.js
for webpack
entry
attribute. Specify an export file for webpack
through the output
bundle.js
.
When webpack
plurality entry
time, a entry
should correspond to a output
, then the output file name to replace the need to use declarations to ensure uniqueness of the filename.
Example:
module.exports = {
entry: {
app: './one.js',
search: './two.js'
},
output: {
path: __dirname + '/dist',
filename: '[name].js',
}
}
The final item in the root directory dist
folder generated one.js
and two.js
two bundle
file.
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。