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
- Host: GitHub
- URL: https://github.com/kushtrimh/java-template-engine-webpack-plugin
- Owner: kushtrimh
- License: mit
- Created: 2021-11-02T22:10:40.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-04-16T09:56:32.000Z (about 3 years ago)
- Last Synced: 2025-10-09T09:50:10.639Z (8 months ago)
- Topics: java-template-engine, javascript, webpack-plugin
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/java-template-engine-webpack-plugin
- Size: 153 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Java Template Engine Webpack Plugin
[](https://www.npmjs.com/package/java-template-engine-webpack-plugin)

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.|