Launch Week Day 5: Introducing Reachability for PHP.Learn More
Socket
Book a DemoSign in
Socket

java-template-engine-webpack-plugin

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

java-template-engine-webpack-plugin

Plugin extension for html-webpack-plugin, that injects code for Java template engines

latest
Source
npmnpm
Version
0.2.3
Version published
Maintainers
1
Created
Source

Java Template Engine Webpack Plugin

npm_version build workflow

A plugin extension for html-webpack-plugin that injects code for Java template engines.

Supported engines

  • Thymeleaf (thymeleaf)
  • Java Server Pages (jsp)

Installation

npm i --save-dev java-template-engine-webpack-plugin

Usage

const HtmlWebpackPlugin = require('html-webpack-plugin')
const JavaTemplateEngineWebpackPlugin = require('java-template-engine-webpack-plugin');

module.exports = {
  entry: 'index.js',
  output: {
    path: __dirname + '/dist',
    filename: 'bundle.js'
  },
  plugins: [
    new HtmlWebpackPlugin(),
    new JavaTemplateEngineWebpackPlugin(HtmlWebpackPlugin, {engine: 'thymeleaf'})
  ]
}

The example below shows how the output of index.html is changed after adding the plugin with thymeleaf as the engine.

Before

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Webpack App</title>
    <link rel="stylesheet" href="styles.css">
  </head>
  <body>
    <div id="root"></div>
    <script src="bundle.js"></script>
  </body>
</html>

After

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Webpack App</title>
    <link rel="stylesheet" th:href="@{styles.css}">
  </head>
  <body>
    <div id="root"></div>
    <script th:src="@{bundle.js}"></script>
  </body>
</html>

Options

NameTypeDefaultDescription
engineString''The engine to be used, please check supported engines section.
addLeadingSlashBooleanfalseAdds a leading slash to the attribute if its missing.
static/image.png becomes /static/image.png
removeLeadingSlashBooleanfalseRemoves a leading slash from the attribute if its present.
/static/image.png becomes static/image.png
removeDotSegmentsBooleanfalseRemoves dot-segments from the attribute.
../../static/image.png becomes static/image.png
./static/image.png becomes static/image.png
.static/image.png becomes static/image.png
removeOriginalAttributesBooleantrueRemoves the original src and href attributes. Only valid when using thymeleaf engine.
useJSTLBooleantrueUses the JSTL <c:url> tag when modifying attributes. Only valid when using jsp engine.

Keywords

webpack

FAQs

Package last updated on 16 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts