Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save popuguytheparrot/2f4b91feca057807551df7f99b6217c7 to your computer and use it in GitHub Desktop.
Save popuguytheparrot/2f4b91feca057807551df7f99b6217c7 to your computer and use it in GitHub Desktop.
node_modules в vendor
поясню:
1) Сначала выделяем все что используется более 3х раз в common асинхронный.
2) Из остатков экстрактим node_modules из всех дочерних чанков
3) Все пихаем в entry chunk
new webpack.optimize.CommonsChunkPlugin({
name: 'app',
async: 'common',
children: true,
deepChildren: true,
minChunks: (module, count) => {
return count >= 3 && module.context && !module.context.includes('node_modules');
},
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'app',
children: true,
deepChildren: true,
minChunks: (module) => {
if (module.resource && (/^.*\.(css|scss|sass)$/).test(module.resource)) {
return false;
}
return module.context && module.context.includes('node_modules');
},
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: (module) => {
if (module.resource && (/^.*\.(css|scss|sass)$/).test(module.resource)) {
return false;
}
return module.context && module.context.includes('node_modules');
},
}),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment