File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -115,10 +115,11 @@ class HtmlWebpackPlugin {
115115
116116 const minify = this . options . minify ;
117117 if ( minify === true || ( minify === 'auto' && isProductionLikeMode ) ) {
118- /** @type { import('html-minifier').Options } */
118+ /** @type { import('html-minifier-terser ').Options } */
119119 this . options . minify = {
120- // https://github. com/kangax /html-minifier#options-quick-reference
120+ // https://www.npmjs. com/package /html-minifier-terser #options-quick-reference
121121 collapseWhitespace : true ,
122+ keepClosingSlash : true ,
122123 removeComments : true ,
123124 removeRedundantAttributes : true ,
124125 removeScriptTypeAttributes : true ,
Original file line number Diff line number Diff line change @@ -2304,4 +2304,27 @@ describe('HtmlWebpackPlugin', () => {
23042304 ]
23052305 } , [ / < s c r i p t d e f e r = " d e f e r " .+ < l i n k h r e f = " s t y l e s .c s s " / ] , null , done ) ;
23062306 } ) ;
2307+
2308+ it ( 'should keep closing slashes from the template' , done => {
2309+ testHtmlPlugin ( {
2310+ mode : 'production' ,
2311+ entry : path . join ( __dirname , 'fixtures/theme.js' ) ,
2312+ output : {
2313+ path : OUTPUT_DIR ,
2314+ filename : 'index_bundle.js'
2315+ } ,
2316+ module : {
2317+ rules : [
2318+ { test : / \. c s s $ / , use : [ MiniCssExtractPlugin . loader , 'css-loader' ] }
2319+ ]
2320+ } ,
2321+ plugins : [
2322+ new HtmlWebpackPlugin ( {
2323+ scriptLoading : 'defer' ,
2324+ templateContent : '<html><body> <selfclosed /> </body></html>'
2325+ } ) ,
2326+ new MiniCssExtractPlugin ( { filename : 'styles.css' } )
2327+ ]
2328+ } , [ / < s e l f c l o s e d \/ > / ] , null , done ) ;
2329+ } ) ;
23072330} ) ;
You can’t perform that action at this time.
0 commit comments