webpack入口起点【entry points】的详细配置(二)

1.单个入口语法

用法:entry: string|Array<string>

const config = {
  entry: {
    main: './path/to/my/entry/file.js'
  }
};

简写:

const config = {
  entry: './path/to/my/entry/file.js'
};

module.exports = config;

2.对象语法

用法:entry: {[entryChunkName: string]: string|Array<string>}

const config = {
  entry: {
    app: './src/app.js',
    vendors: './src/vendors.js'
  }
};

能创建多个独立的依赖视图

常见场景:

分离应用程序【app】和第三方库【vendor】入口

const config = {
  entry: {
    app: './src/app.js',
    vendors: './src/vendors.js'
  }
};

多页面应用程序

const config = {
  entry: {
    pageOne: './src/pageOne/index.js',
    pageTwo: './src/pageTwo/index.js',
    pageThree: './src/pageThree/index.js'
  }
};

 

posted @ 2019-08-19 19:53  瑞瑞大人  阅读(432)  评论(0编辑  收藏  举报