Giter Club home page Giter Club logo

Comments (19)

toverux avatar toverux commented on June 19, 2024 1

I use it this way, and that works :

{ test: /\.html$/, loader: 'html?minimize=false', exclude: [root('src', 'index.html')] },

https://github.com/webpack/html-loader/blob/master/index.js#L68

And yes, I agree, these are very destructive defaults :/

from html-loader.

ccorcos avatar ccorcos commented on June 19, 2024 1

Whats going on is there are two configurations to effectively turn on minification. One is the htmlLoader field. so if you put htmlLoader: { minimize: false }, then that will override this.minimize which I believe is set when running webpack -p

from html-loader.

ghjagus avatar ghjagus commented on June 19, 2024 1

Is there a way that minimize the html string but keep case sensitive?Because i use PascalCase-style to name my components.

from html-loader.

ccorcos avatar ccorcos commented on June 19, 2024

These defaults are terrible:

https://github.com/webpack/html-loader/blob/master/index.js#L71-L88

<!DOCTYPE html> <html lang=en> <head> <meta charset=UTF-8> <title>Skeleton App</title> <meta name=viewport content="width=device-width,initial-scale=1"> </head> <body> <div id=root></div> <img src=<%=ROOT_URL%>/7d3f8da0eae1b0de9b3e8ef7ac4615b4.png /> <script type="text/javascript" src="<%=ROOT_URL%>/index-542e410e44a0f3d636e0.js"></script></body> </html>

from html-loader.

ccorcos avatar ccorcos commented on June 19, 2024

I think it would be great if they were configurable but I cant figure out how to do that. Perhaps its a porblem with using it inside HtmlWebpackPlugin

from html-loader.

ccorcos avatar ccorcos commented on June 19, 2024

hmm. the problem is I'm using it with the Webpack HTML Plugin...

from html-loader.

toverux avatar toverux commented on June 19, 2024

Me too :) And the HtmlWebpackPlugin does not seem to cause any problem here, it's just html-loader's minimification, at least in my configuration (note that I also have excluded index.html in html-loader's configuration):

const BASE_CONFIG = {
    plugins: [
        new HtmlWebpackPlugin({ template: 'src/index.html' })
    ],

    module: {
        loaders: [
            { test: /\.html$/, loader: 'html?minimize=false', exclude: [root('src', 'index.html')] }
        ]
    }
};

from html-loader.

imvetri avatar imvetri commented on June 19, 2024

You can try the following? Please dont mind. i didnt try the code, I could guess this from the code
https://github.com/webpack/html-loader/blob/master/index.js#L68 difference.

htmlLoader:{"removeComments : false",
"removeCommentsFromCDATA : false",
"removeCDATASectionsFromCDATA : false",
"collapseWhitespace : false",
"conservativeCollapse : false",
"removeAttributeQuotes : false",
"useShortDoctype : false",
"keepClosingSlash : false",
"minifyJS : false",
"minifyCSS : false",
"removeScriptTypeAttributes : false",
"removeStyleTypeAttributes : false"}

from html-loader.

imvetri avatar imvetri commented on June 19, 2024

@ccorcos Can i request something? Could you share information on How you specifically opened the code difference at https://github.com/webpack/html-loader/issues/url ?

Above comment is my first comment on a open source 💃 yay. and i am curious how you were able to point at specific piece of code.

from html-loader.

ccorcos avatar ccorcos commented on June 19, 2024

So I'm using the html webpack plugin like this:

      new HtmlWebpackPlugin({
        template: `!html!${config.html}`,
        inject: 'body',
      }),

It appears that adding any inline query params causes errors, and when I use something like...

    htmlLoader: {
      removeComments: false,
      removeCommentsFromCDATA: false,
      removeCDATASectionsFromCDATA: false,
      collapseWhitespace: false,
      conservativeCollapse: false,
      removeAttributeQuotes: false,
      useShortDoctype: false,
      keepClosingSlash: false,
      minifyJS: false,
      minifyCSS: false,
      removeScriptTypeAttributes: false,
      removeStyleTypeAttributes: false
    },

... it doesnt work either.

@imvetri When you are looking at code on github, click a line number and it it will get highlighted and change the url. You can also shift-click to another location to highlight a range.

from html-loader.

jackyon avatar jackyon commented on June 19, 2024

not working for me either, the html code still get compressed..
is there any solution for this issue?

from html-loader.

imvetri avatar imvetri commented on June 19, 2024

Can someone help me understand with this condition
https://github.com/webpack/html-loader/blob/master/index.js#L68

I suspect this line and it is taking program control inside the IF block all ways.

Hence minify=true is not working?

from html-loader.

abelokon avatar abelokon commented on June 19, 2024

+1 same problem using HtmlWebpackPlugin - any updates?

from html-loader.

ccorcos avatar ccorcos commented on June 19, 2024

I didnt figure anything out -- at then end of the day, it does work...

from html-loader.

joshwiens avatar joshwiens commented on June 19, 2024

@abelokon There are a few "problems" mentioned here. The original was the defaults for html loader in regards to minification which has been changed. The second was effectively minifing twice.

Could you be a bit more specific to which issue you are referencing?

from html-loader.

abelokon avatar abelokon commented on June 19, 2024

@d3viant0ne As already mentioned I'm also using HtmlWebpackPlugin and trying figure out how to turn off the minification of my html files. Since the first snippet posted here didn't work for me either, I agreed.

from html-loader.

eladchen avatar eladchen commented on June 19, 2024

FYI: Looking at this commit @ index.js:19

It seems that there is an issue with how "configKey" is looked up. The config key is looked up using
hasOwnProperty( ... ) on 'context.options' - This will never yield true, as the key does exists, but on 'context.options.prototype'.

Edit:
To overcome this alleged issue, the only way to provide options, is to use the syntax suggested in the loaders query parameters docs.

In order to disable minimizing, use:

loaders: [ {
    test:   /\.html$/,
    loader: 'html-loader',
    query:  {
        minimize: false
    }
} ]

Please correct me if I'm wrong.

from html-loader.

hemanth avatar hemanth commented on June 19, 2024

Thanks for reporting, this is fixed in #116.

from html-loader.

amirhosein993 avatar amirhosein993 commented on June 19, 2024

I use it this way, and that works :

{ test: /\.html$/, loader: 'html?minimize=false', exclude: [root('src', 'index.html')] },

https://github.com/webpack/html-loader/blob/master/index.js#L68

And yes, I agree, these are very destructive defaults :/

where to write this?
thanks

from html-loader.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.