1. const path = require('path')
    2. const HtmlWebpackPlugin = require('html-webpack-plugin')
    3. module.exports = {
    4. mode: 'development',
    5. entry: {
    6. index1: {
    7. import: ['./src/index.js', './src/index3.js'],
    8. dependOn: 'lodash',
    9. filename: 'bundle1/index.js'
    10. },
    11. index2: {
    12. import: './src/index2.js',
    13. filename: 'bundle2/index.js'
    14. },
    15. lodash: {
    16. import: 'lodash',
    17. filename: 'common/lodash.js'
    18. }
    19. },
    20. plugins: [
    21. new HtmlWebpackPlugin({
    22. title: '多页面1', // <%= htmlWebpackPlugin.title %>
    23. template: './src/index.html',
    24. inject: 'body',
    25. filename: 'bundle1/index.html',
    26. chunks: ['index1','lodash'],
    27. publicPath: 'http://www.aa.com/'
    28. }),
    29. new HtmlWebpackPlugin({
    30. title: '多页面2',
    31. template: './src/index2.html',
    32. inject: 'body',
    33. filename: 'bundle2/index.html',
    34. chunks: ['index2'],
    35. publicPath: 'http://www.bb.com/'
    36. })
    37. ],
    38. output: {
    39. clean: true
    40. }
    41. }