跳到主要内容

认识

2024年11月23日
柏拉文
越努力,越幸运

一、认识


entry 开始应用程序打包过程的一个或多个起点。如果传入数组,则会处理所有条目。

二、语法


2.1 Single Entry

module.exports = {
entry: './home.js'
};
module.exports = {
entry: ["./home.js", "./about.js"]
};

2.2 Multiple Entry

module.exports = {
entry: {
home: './home.js',
about: './about.js',
contact: ["./homeXXX.js", "./aboutXXX.js"]
},
};

3.3 Multiple Entry Object

module.exports = {
//...
entry: {
home: './home.js',
shared: ['react', 'react-dom', 'redux', 'react-redux'],
catalog: {
import: './catalog.js',
filename: 'pages/catalog.js',
dependOn: 'shared',
chunkLoading: false, // Disable chunks that are loaded on demand and put everything in the main chunk.
},
personal: {
import: './personal.js',
filename: 'pages/personal.js',
dependOn: 'shared',
chunkLoading: 'jsonp',
asyncChunks: true, // Create async chunks that are loaded on demand.
layer: 'name of layer', // set the layer for an entry point
},
},
};