2

I have been working on a Webpack project. For anyone unfamiliar with Webpack, it is a bundler that takes all your files and spits out a final product.

I wanted to inject one HTML file into another, like an import or require(). I have been using this GitHub template to help me piece together my project. https://github.com/dharmikumbhani/webpack-multipage-starter

In webpack-multipage-starter/src/page-index/index.html on line 10 and 11 there is the following:

<!-- intercepted by a resourceQuery in the webpack config -->
<%= require('../partials/nav.html?raw') %>

This line gets intercepted by a resourceQuery (in the webpack.common.js configuration) and the HTML file is injected into this position.

What is the meaning of this HTML tag?

<%= =>

All I know is that it holds a Java-Script expression which gets evaluated during the Webpack build process.

voxelfox
  • 23
  • 2
  • [https://stackoverflow.com/questions/7996695/what-is-the-difference-between-and-in-erb-in-rails](https://stackoverflow.com/questions/7996695/what-is-the-difference-between-and-in-erb-in-rails) – Rob Moll Jul 23 '21 at 14:22
  • @RobMoll — Webpack isn't Ruby though – Quentin Jul 23 '21 at 14:27
  • Hi, @RobMoll I had a look into this. Is ruby related to HTML, JS, or Webpack? If so where and how? – voxelfox Jul 23 '21 at 14:29
  • @voxelfox — Ruby is a programming language. JS is a programming language. Webpack is written in JS not Ruby. – Quentin Jul 23 '21 at 14:31
  • @Quentin Precisely what I thought. The closest that I can get is JSP expression tags. (https://www.geeksforgeeks.org/jsp-expression-tag/) but that's Java. – voxelfox Jul 23 '21 at 14:31

1 Answers1

0

It is an EJS template. It is used by html-webpack-plugin to generate html pages typically for bootstrapping your Multipage apps or SPA apps.

Harshal Patil
  • 17,838
  • 14
  • 60
  • 126