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+ const ThymeleafEngine = require ( './thymeleaf' )
2+
3+ module . exports = {
4+ thymeleaf : ThymeleafEngine
5+ }
Original file line number Diff line number Diff line change 1+ class ThymeleafEngine {
2+ applyForScripts ( scripts ) {
3+ scripts . forEach ( script => {
4+ script . attributes [ 'th:src' ] = '@{' + script . attributes . src + '}' ;
5+ delete script . attributes [ 'src' ] ;
6+ } ) ;
7+ }
8+
9+ applyForStyles ( styles ) {
10+ styles . forEach ( style => {
11+ style . attributes [ 'th:href' ] = '@{' + style . attributes . href + '}' ;
12+ delete style . attributes [ 'href' ] ;
13+ } ) ;
14+ }
15+ }
16+
17+ module . exports = ThymeleafEngine
Original file line number Diff line number Diff line change 1+ const engines = require ( './engines/engines' )
2+
3+ const supportedEngines = [ 'thymeleaf' ] ;
4+
5+ class JavaTemplateEngineWebpackPlugin {
6+
7+ constructor ( plugin , options ) {
8+ this . options = options || { } ;
9+ if ( supportedEngines . includes ( this . options . engine ) ) {
10+ this . templateEngine = new engines [ this . options . engine ] ;
11+ }
12+ this . htmlWebpackPlugin = plugin ;
13+ }
14+
15+ apply ( compiler ) {
16+ compiler . hooks . compilation . tap ( 'JavaTemplateEngineWebpackPlugin' , ( compilation ) => {
17+ this . htmlWebpackPlugin . getHooks ( compilation ) . alterAssetTags . tapAsync (
18+ 'JavaTemplateEngineWebpackPlugin' ,
19+ ( data , cb ) => {
20+ if ( this . templateEngine ) {
21+ this . templateEngine . applyForScripts ( data . assetTags . scripts ) ;
22+ this . templateEngine . applyForStyles ( data . assetTags . styles ) ;
23+ }
24+ cb ( null , data ) ;
25+ }
26+ )
27+ } ) ;
28+ }
29+ }
30+
31+ module . exports = JavaTemplateEngineWebpackPlugin
Original file line number Diff line number Diff line change 2222 "bugs" : {
2323 "url" : " https://github.com/kushtrimh/java-template-engine-webpack-plugin/issues"
2424 },
25- "homepage" : " https://github.com/kushtrimh/java-template-engine-webpack-plugin#readme" ,
26- "devDependencies" : {
27- "html-webpack-plugin" : " ^5.5.0"
28- }
25+ "homepage" : " https://github.com/kushtrimh/java-template-engine-webpack-plugin#readme"
2926}
You can’t perform that action at this time.
0 commit comments