diff --git a/README.md b/README.md index 7aa22eb4..49296c47 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,38 @@ module: { } ``` +The enabled rules for minimizing by default are the following ones: + - removeComments + - removeCommentsFromCDATA + - removeCDATASectionsFromCDATA + - collapseWhitespace + - conservativeCollapse + - removeAttributeQuotes + - useShortDoctype + - keepClosingSlash + - minifyJS + - minifyCSS + - removeScriptTypeAttributes + - removeStyleTypeAttributes + + The rules can be disabled using the following options in your `webpack.conf.js` + +```js +module: { + rules: [{ + test: /\.html$/, + use: [ { + loader: 'html-loader', + options: { + minimize: true, + removeComments: false, + collapseWhitespace: false + } + }], + }] +} +``` + ### 'Root-relative' URLs For urls that start with a `/`, the default behavior is to not translate them. diff --git a/test/loaderTest.js b/test/loaderTest.js index a353ed46..285fdfd6 100644 --- a/test/loaderTest.js +++ b/test/loaderTest.js @@ -57,6 +57,35 @@ describe("loader", function() { 'module.exports = "

#{number} {customer}

{title}

";' ); }); + + it("should preserve comments and white spaces when minimizing (via webpack config property)", function() { + loader.call({ + minimize: true, + options: { + htmlLoader: { + removeComments: false, + collapseWhitespace: false + } + } + }, '

#{number} {customer}

{title}

').should.be.eql( + 'module.exports = "

#{number} {customer}

{title}

";' + ); + }); + + it("should preserve comments and white spaces when minizing (via webpack config property)", function() { + loader.call({ + options: { + htmlLoader: { + minimize: true, + removeComments: false, + collapseWhitespace: false + } + } + }, '

#{number} {customer}

{title}

').should.be.eql( + 'module.exports = "

#{number} {customer}

{title}

";' + ); + }); + it("should treat attributes as case sensitive", function() { loader.call({ minimize: true,