tolyo / html-pages-brunch

Brunch plugin for compiling and minifying HTML files
MIT License
11 stars 4 forks source link

Plugin works for too long #1

Closed snowindy closed 9 years ago

snowindy commented 9 years ago

Hey, I tried to place all files (~1000 html files) that previously were in assets folder to app folder. This was done to make html and corresponding js files close to each other - so I don't have dig into assets folder every time I work on js file.

I tried to switch off the minifier with config, it did not help.

brunch watch: before this change it took ~ 4s to complete initial watch iteration brunch watch: after this change it took more than 5 minutes, I stopped waiting and cancelled

I used this config:

plugins:
    htmlPages:
      removeComments: false
      removeCommentsFromCDATA: false
      removeCDATASectionsFromCDATA: false
      collapseBooleanAttributes: false
      useShortDoctype: false
      removeEmptyAttributes: false
      removeScriptTypeAttributes: false
      removeStyleLinkTypeAttributes: false
      collapseWhitespace: false
      minifyJS: false
      minifyCSS: false
      destination : (path) -> path.replace /^app[\/\\](.*)\.html$/, "$1.html"
tolyo commented 9 years ago

Hey The best use case for the plugin is a large Angular app with a module-based structure akin to ngBoilerplate, so based on your description above - you're using it exactly as intended.

Can you confirm that you're experiencing this with the default config? If so can you confirm that you're experiencing this with 10 files? 100 files?

tolyo commented 9 years ago

You're missing htmlMin config. Try this:

    htmlPages: {
      htmlMin: {
        removeComments: false,
        removeCommentsFromCDATA: false,
        removeCDATASectionsFromCDATA: false,
        collapseBooleanAttributes: false,
        useShortDoctype: false,
        removeEmptyAttributes: false,
        removeScriptTypeAttributes: false,
        removeStyleLinkTypeAttributes: false,
        collapseWhitespace: false,
        minifyJS: false,
        minifyCSS: false
      },
      destination: function(path) {
        return path.replace(/^app[\/\\](.*)\.html$/, "$1.html");
      }
    }
snowindy commented 9 years ago

In fact, this file was the root cause of slowness. When your plugin used html-minifier 0.7.2 on this file it hanged forever. Apparently it's a bug of minifier, I am creating an issue for them.

<div class="widget-title pm-modal-header"><span class="icon"> <i class="icon-align-justify"></i></span>
    <h5 ng-i18next="app.logged-in.template.raw-template-code"></h5>
</div>

<div class="modal-body pm-modal-full-screen-body pm-boxed-content" style="padding: 40px 0px 60px 0px;>
    <div class="pm-boxed-content-relative">     
        <div class="spinner-large-white" ng-show="loadingTemplate == true"></div>   
        <textarea id="templateCode" pm-code-editor mode="template.mode" content="template.content" width="100%" height="100%"></textarea>
    </div>
</div>
<div class="modal-footer pm-wizard-form-actions">
    <button class="btn btn-primary" ng-click="ok()"><i class="icon-ok icon-white pm-button-icon"></i>OK</button>
</div>
tolyo commented 9 years ago

Its hicking up here:

<div class="modal-body pm-modal-full-screen-body pm-boxed-content" style="padding: 40px 0px 60px 0px;>

Style attribute is not closed.

snowindy commented 9 years ago

Off topic: Could you also tell me how to install this plugin globally? I tried 'npm install -g html-pages-brunch' and this leads to this:

c:\workspace\propzmedia-all\mcloud-studio\mcloud-studio-web\src\main\webapp\brunch>npm install -g html-pages-brunch
html-pages-brunch@1.0.5 C:\Users\eg\AppData\Roaming\npm\node_modules\html-pages-brunch
├── mkdirp@0.3.5
├── html-minifier@0.7.2 (relateurl@0.2.6, change-case@2.3.0, concat-stream@1.4.8, cli@0.6.6, uglify-js@2.4.23, clean-css@3.1.9)
└── lodash@3.9.3

c:\workspace\propzmedia-all\mcloud-studio\mcloud-studio-web\src\main\webapp\brunch>brunch watch
c:\Users\eg\AppData\Roaming\npm\node_modules\brunch\lib\watch.js:446
          throw new Error("You probably need to execute `npm install` to insta
                ^
Error: You probably need to execute `npm install` to install brunch plugins. Error: Cannot find module ....
tolyo commented 9 years ago

sudo npm install -g html-pages-brunch

snowindy commented 9 years ago

This is exactly what I did:

c:\workspace\propzmedia-all\mcloud-studio\mcloud-studio-web\src\main\webapp\brunch>npm install -g html-pages-brunch

I use windows, no sudo here.

tolyo commented 9 years ago

Right. Well its not downloading those dependencies so I am not sure what the Windows solution for that would be. Sorry can't help.

snowindy commented 9 years ago

no problem, thanks.