An open API service indexing awesome lists of open source software.

https://github.com/kushtrimh/java-template-engine-webpack-plugin

A plugin extension for html-webpack-plugin that injects code for Java template engines
https://github.com/kushtrimh/java-template-engine-webpack-plugin

java-template-engine javascript webpack-plugin

Last synced: 5 months ago
JSON representation

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

Awesome Lists containing this project

README

          

# Java Template Engine Webpack Plugin
[![npm_version](https://img.shields.io/npm/v/java-template-engine-webpack-plugin?color=blue)](https://www.npmjs.com/package/java-template-engine-webpack-plugin)
![build workflow](https://github.com/kushtrimh/java-template-engine-webpack-plugin/actions/workflows/node.js.yml/badge.svg)

A plugin extension for [html-webpack-plugin](https://github.com/jantimon/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

```js
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*
```html



Webpack App





```

*After*
```html



Webpack App





```

---

### Options
|Name|Type|Default|Description|
|--------|---------|--------|---------|
|`engine`|`String`|`''`|The engine to be used, please check [supported engines](#supported-engines) section.|
|`addLeadingSlash`|`Boolean`|`false`|Adds a leading slash to the attribute if its missing.
_static/image.png_ becomes _/static/image.png_|
|`removeLeadingSlash`|`Boolean`|`false`|Removes a leading slash from the attribute if its present.
_/static/image.png_ becomes _static/image.png_|
|`removeDotSegments`|`Boolean`|`false`|Removes 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_|
|`removeOriginalAttributes`|`Boolean`|`true`|Removes the original `src` and `href` attributes. Only valid when using `thymeleaf` engine.|
|`useJSTL`|`Boolean`|`true`|Uses the `JSTL` `` tag when modifying attributes. Only valid when using `jsp` engine.|