Skip to content
This repository has been archived by the owner on Apr 20, 2018. It is now read-only.

Smarter, more customizable 'type' for blocks #219

Open
jamesplease opened this issue Nov 5, 2013 · 2 comments
Open

Smarter, more customizable 'type' for blocks #219

jamesplease opened this issue Nov 5, 2013 · 2 comments

Comments

@jamesplease
Copy link

Presently, the blocks in usemin are set up like this:

<!-- build:<type>(alternate search path) <path> -->

where <type> is either js or css. If it was a good idea to limit the usemin task to one of two types, it seems like it'd be easy to detect this on the fly. References to external scripts use the <script src="">, and references to external stylesheets use <link href="">. This is enough information to determine whether the block is a js block or css block.

All of the parsing is already done for us, too. In file.js, something like:

last.type = asset[1] === 'src' ? 'js' : 'css';

would get the job done (you could set it up so that it uses, say, the first line of the block only)

With that said, I don't think it should limit you to just two types in the first place. What if you want to handle some of your scripts differently from others? One instance I can see this being useful would be source maps; you might want to generate source maps for some of your blocks, but not others.

Instead of the two-type limitation, usemin could instead allow for arbitrary types, like jsMap. For these non-standard ones, you would be required to generate the flow or it would throw an error.

If you ignore the type altogether, it could use the method I described at the beginning of this post to automatically assign the block to being js or css.

This would increase the power and flexibility of usemin a great deal, and it could easily be written to be backwards-compatible.

If I made a pull request with this feature, is there a chance it would merged?

@corbanbrook
Copy link

This is along the same lines you are talking about: #230

I like the idea of getting rid of type requirement (js and css) and just having the target specified.

@keenmedia
Copy link

What you are looking for might be possible with "grunt-file-blocks": https://github.com/rrharvey/grunt-file-blocks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants