entry
entry
属性支持如下形式:
-
string
entry: './src/app.js' 复制代码
打包结果:
. ├── index.html └── main.e509da2eaba20c6b857e.js 复制代码
-
string[]
entry: [ './src/app.js', './src/polyfill.js', ] 复制代码
打包结果:
-
object
entry: { app: './src/app.js', polyfill: './src/polyfill.js', vendor: [ 'lodash', 'axios' ] } 复制代码
对象的值可以是字符串或者字符串数组
打包结果:
. ├── index.html ├── app.57f0c1853de6b01d403f.js ├── polyfill.57f0c1853de6b01d403f.js └── vendor.57f0c1853de6b01d403f.js 复制代码
entry
对象中的每一项都被打包到了一个单独的文件中 -
function
-
返回字符串
entry: () => './src/app.js' 复制代码
打包结果:
. ├── index.html └── main.e509da2eaba20c6b857e.js 复制代码
-
返回字符串数组
entry: () => [ './src/app.js', './src/polyfill.js', 'lodash' ] 复制代码
打包结果:
. ├── index.html └── main.1d2fe2315df27e480233.js 复制代码
-
返回对象
entry: () => ({ app: './src/app.js', polyfill: './src/polyfill.js', vendor: [ 'lodash', 'axios' ] }) 复制代码
打包结果:
. ├── app.57f0c1853de6b01d403f.js ├── index.html ├── polyfill.57f0c1853de6b01d403f.js └── vendor.57f0c1853de6b01d403f.js 复制代码
-