html拼接ejs,webpack html (ejs) include other templates

这篇博客探讨了如何在Webpack配置中实现HTML文件的模块化,作者分享了他们的Webpack配置,尝试通过HtmlWebpackPlugin将HTML文件拆分成多个部分,并引入到主模板中。尽管尝试了多种方法,但未能成功。他们寻求帮助,希望找到解决这个问题的方法。
摘要由CSDN通过智能技术生成

So this is my webpack config :

import path from 'path';

var HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {

entry: {

index: './dev/index.js'

},

output: {

path: path.join(__dirname, 'dist'),

// publicPath: 'http://localhost:3000/',

filename: 'bundle.js',

chunkFilename: '[id].bundle.js'

},

module: {

loaders: [

{

test: /\.js$/,

exclude: path.resolve(__dirname, "node_modules"),

loader: 'babel-loader'

}

]

},

plugins: [

new HtmlWebpackPlugin({

hash: true,

template: 'ejs!./dev/index.ejs',

inject: 'body'

})

]

};

My index.ejs file :

Document

My folder structure :

dev/

/assets

/html

/one

1.ejs

1.scss

1.js

/two

/three

index.js

index.ejs

I want to modularize my html file so I want to include them...

I've tried a lot of methods including another template, but none of them worked...

Can someone give me any ideea of how can I make this work?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值