美文网首页
webpack打包多页应用

webpack打包多页应用

作者: Victor_818 | 来源:发表于2019-05-14 14:10 被阅读0次

    假设有两个入口文件home.js和other.js需要打包

    let path = require('path);
    let HtmlWebpackPlugin = require('html-webpack-plugin);
    
    module.exports = {
        mode: 'development',
        entry: {
            home: './src/index.js',
            other: './src/other.js'
        },
        output: {
            filename: '[name].js',
            path: path.resolve( __dirname, 'dist' )
        },
        plugins: [
            new HtmlWebpackPlugin ({
                  template: './index.html',
                  filename: 'home.html',
                  chunks: ['home']
            }),
            new HtmlWebpackPlugin ({
                  template: './index.html',
                  filename: 'home.html',
                  chunks: ['other']
            })
        ]
    }
    

    相关文章

      网友评论

          本文标题:webpack打包多页应用

          本文链接:https://www.haomeiwen.com/subject/ghesaqtx.html