File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- # java-template-engine-webpack-plugin
1+ # java-template-engine-webpack-plugin
2+
3+ A plugin extension for [ html-webpack-plugin] ( https://github.com/jantimon/html-webpack-plugin ) that injects code for Java template engines.
4+
5+ ## Supported engines
6+
7+ - Thymeleaf (` thymeleaf ` )
8+
9+ ## Installation
10+
11+ ` npm i --save-dev java-template-engine-webpack-plugin `
12+
13+ ## Usage
14+
15+ ``` js
16+ const HtmlWebpackPlugin = require (' html-webpack-plugin' )
17+ const JavaTemplateEngineWebpackPlugin = require (' java-template-engine-webpack-plugin' );
18+
19+ module .exports = {
20+ entry: ' index.js' ,
21+ output: {
22+ path: __dirname + ' /dist' ,
23+ filename: ' bundle.js'
24+ },
25+ plugins: [
26+ new HtmlWebpackPlugin (),
27+ new JavaTemplateEngineWebpackPlugin (HtmlWebpackPlugin, {engine: ' thymeleaf' })
28+ ]
29+ }
30+ ```
31+
32+ Adding the plugin for ` thymeleaf ` in this case, would change the ` HTML ` as follows
33+
34+ ``` HTML
35+ <!DOCTYPE html>
36+ <html >
37+ <head >
38+ <meta charset =" utf-8" >
39+ <title >Webpack App</title >
40+ <link rel =" stylesheet" th:href =" @{styles.css}" >
41+ </head >
42+ <body >
43+ <div id =" root" ></div >
44+ <script th:src =" @{bundle.js}" ></script >
45+ </body >
46+ </html >
47+ ```
48+
49+ ### Options
50+ | Name| Description|
51+ | --------| ---------|
52+ | ` engine ` | The engine to be used, please check [ supported engines] ( #supported-engines ) section.|
You can’t perform that action at this time.
0 commit comments