gpt4 book ai didi

html-webpack-plugin - 如何将 html-webpack-plugin 与现有的 express 模板一起使用?

转载 作者:行者123 更新时间:2023-12-03 17:39:35 26 4
gpt4 key购买 nike

我已经安装了 express-generetor npm 模块,并且喜欢使用作为模板的 Jade 文件来构建项目的结构。但是我也喜欢使用生成自己的文件的 HTML-webpack-plugin,集成这两种方法的最佳方法是什么?

最佳答案

  • 第一步:

  • 生成您的 html 文件:
    module.exports = {
    entry: {
    'page1': './apps/page1/scripts/main.js',
    'page2': './apps/page2/src/main.js'
    },
    output: {
    path: __dirname,
    filename: "apps/[name]/build/bundle.js"
    },
    plugins: [
    new HtmlWebpackPlugin({
    inject: true,
    chunks: ['page1'],
    filename: 'apps/page1/build/index.html'
    }),
    new HtmlWebpackPlugin({
    inject: true,
    chunks: ['page2'],
    filename: 'apps/page2/build/index.html'
    })
    ]
    };
  • Step2:将生成的 html 文件添加到您的 Jade 文件中

    包括 ../../public/index.html
  • 关于html-webpack-plugin - 如何将 html-webpack-plugin 与现有的 express 模板一起使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39501555/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com