【webpack】entry 和output的详细介绍
2017-02-19 23:37
375 查看
entry
entry是指页面中的入口文件。也就是打包从哪个文件开始。
entry的值有三种类型 : 1.字符串,2.数组, 3.对象
1.字符串
指定从这个文件路径下面的文件作为打包的入口文件entry: './app.js'2.数组
当存在多个入口时 ,可以使用 Array 的方式,比如依赖第三方库 bootstrap ,最终 bootstrap 会被追加到打包好的 index.js 中,数组中的最后一个会被 export。
3.对象
设置多个打包目标。每一对键值对都对应着一个入口文件。常用语多页面入口文件配置
output
是指生成的文件输出到哪个地方去。主要有两个属性 path和 filename。其次就是publicPath 和chunkFileName
也可能是从 url 访问的情况下的路径
publicPath: 用于存放静态资源文件路径。 //webpack-dev-server访问的路径
下面是官网描述:
output.publicPath
The
the public URL address of the output files when referenced in a browser. For loaders that embed
or reference assets like images,
used as the
the file when it’s different than their location on disk (as specified by
This can be helpful when you want to host some or all output files on a different domain or on a CDN. The Webpack Dev Server also uses this to determine the path where the output files are expected to be served from. As with
can use the
for a better caching profile.
entry是指页面中的入口文件。也就是打包从哪个文件开始。
entry的值有三种类型 : 1.字符串,2.数组, 3.对象
1.字符串
指定从这个文件路径下面的文件作为打包的入口文件entry: './app.js'2.数组
当存在多个入口时 ,可以使用 Array 的方式,比如依赖第三方库 bootstrap ,最终 bootstrap 会被追加到打包好的 index.js 中,数组中的最后一个会被 export。
{ entry: ['./src/index.js', './vendor/bootstrap.min.js'], output: { path: './dist', filename: "index.js" } }
3.对象
设置多个打包目标。每一对键值对都对应着一个入口文件。常用语多页面入口文件配置
{ entry: { index: './src/index.js', a: './src/a.js' }, output: { path: './dist/', filename: '[name].js' } }
output
是指生成的文件输出到哪个地方去。主要有两个属性 path和 filename。其次就是publicPath 和chunkFileName
path可能对应文件路径,
也可能是从 url 访问的情况下的路径
filename用来配置生成的文件名,
publicPath: 用于存放静态资源文件路径。 //webpack-dev-server访问的路径
chunkFilename:"[name].js"主要用于按需加载。生成块状文件
下面是官网描述:
output.publicPath
The
publicPathspecifies
the public URL address of the output files when referenced in a browser. For loaders that embed
<script>or
<link>tags
or reference assets like images,
publicPathis
used as the
hrefor
url()to
the file when it’s different than their location on disk (as specified by
path).
This can be helpful when you want to host some or all output files on a different domain or on a CDN. The Webpack Dev Server also uses this to determine the path where the output files are expected to be served from. As with
pathyou
can use the
[hash]substitution
for a better caching profile.
相关文章推荐
- webpack---webpack.config.js配置基本要素entry、output、loader、plugins等
- webpack entry和output配置属性
- html-webpack-plugin插件的详细介绍和使用
- 详解webpack的配置文件entry与output
- 入门webpack(三)webpack之entry和output
- webpack entry和output配置属性
- webpack配置entry和output
- output_buffering详细介绍
- web.xml 详细介绍
- web.xml 详细介绍
- web.xml配置详细介绍
- web.xml 详细介绍
- web.xml 详细介绍
- web.config设置之system.webServer 详细介绍,为网站设置默认文档
- web.xml 详细介绍
- ASP.NET中Web.config文件的层次关系详细介绍
- web.xml详细介绍
- output_buffering详细介绍
- web.xml 详细介绍
- web.xml 详细介绍