yeoman / grunt-usemin

[UNMAINTAINED] Replaces references to non-optimized scripts or stylesheets into a set of HTML files (or any templates/views)
BSD 2-Clause "Simplified" License
1.22k stars 338 forks source link

require.js Blocks Support #495

Open ehteshamkafeel opened 9 years ago

ehteshamkafeel commented 9 years ago

The latest changes in usemin has stopped the support for require.js blocks as they are being processed by requirejs task. This has introduced errors in generators, e.g. generator-backbone still using conditional blocks for require.js JS file.

If the block is removed from source file, all works fine except that in dist version of html script declaration doesn't get replaced by dest and revved file. i.e. <script data-main="path/to/main" src-"path/to/requirejs"> from source folder remain as it it is in dist.

I think in this case usemin should still process the block to replace file dest and revved version. I don't know what the proper fix is but If you just remove the line throw new Error('require.js blocks are no more supported.'); in file.js it works as expected.

stephanebachelier commented 9 years ago

@ehteshamkafeel it depends on your workflow, if you build a single file with almond.js or if you still use require.js. This was long debated before. Not sure for know what to do.

brunowego commented 9 years ago

+1

victorbetran commented 9 years ago

Hi,

I have a problem related with this. I want to know how to handle properly the scenario of multipage: https://github.com/requirejs/example-multipage

I have a common module for several pages and page-specific modules for each one. I want to keep the common module because I'll get the benefit of browser caching for an assets that it's repeated in a lot of pages.

AFAIK, the recommendation of using almod it will put all the files in one single file, but in that case I won't get the previous benefit that I mentioned. Does anyone know a properly way to handle this case?

Thanks! Viko