1. const path = require('path');
    2. const HTMLWebpackPlugin = require('html-webpack-plugin');
    3. module.exports = {
    4. entry: {
    5. index: './src/index.js',
    6. another: './src/another-module.js'
    7. },
    8. plugins: [
    9. new HTMLWebpackPlugin({
    10. title: 'Code Splitting'
    11. })
    12. ],
    13. output: {
    14. filename: '[name].bundle.js',
    15. path: path.resolve(__dirname, 'dist')
    16. }
    17. };

    entry的配置,产生chunk.
    这种方法存在一些问题:

    • 如果入口 chunks 之间包含重复的模块,那些重复模块都会被引入到各个 bundle 中。
    • 这种方法不够灵活,并且不能将核心应用程序逻辑进行动态拆分代码。