美文网首页
webpack基础(六)打包多页

webpack基础(六)打包多页

作者: 前端开发爱好者 | 来源:发表于2019-05-25 02:24 被阅读0次

webpack打包多页

const path = require('path');
const htmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
    // 多入口
    mode: 'development',
    entry: {
        home: './src/index.js',
        other: './src/other.js'
    },

    output: {
        //[name]表示home ,other
        filename: '[name]bundle.js',
        path: path.resolve(__dirname, 'dist')
    },
    plugins: [
        new htmlWebpackPlugin({
            template: "./index.html",
            filename: "home.html",
            chunks: ['home']
        }), new htmlWebpackPlugin({
            template: "./index.html",
            filename: "other.html",
            chunks: ['other']
        })
    ]
};

相关文章

网友评论

      本文标题:webpack基础(六)打包多页

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