thegooglecodearchive / minify

Automatically exported from code.google.com/p/minify
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

server-side @imports #50

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Minify should be able to parse @import directives in CSS files (and maybe 
JS?), dynamically add the necessary source files, and strip the @imports 
on output.

This is tricky because currently only the minifier functions see file 
contents and at that point the source list has already been build and 
checked for mtimes.

One solution is to extend Minify_Source to make it take a CSS file and 
internally maintain a "linearized" CSS file containing all the referenced 
style content (without imports), and Minify would see this as one file. It 
would also need to cache a list of the referenced filenames and use the 
max of their mtimes to determine if the linearized file needs to be 
rebuilt. That mtime max would be reported as the source's mtime.

Another problem will be relative URIs within @imported files that live in 
other directories. It would be simplest (for code reuse) to have the CSS 
linearizer rewrite the URIs, so the minifier won't have to.

Original issue reported on code.google.com by mrclay....@gmail.com on 26 Aug 2008 at 3:26

GoogleCodeExporter commented 9 years ago
Good progress in R188. Minify_CSS_Linearizer::linearize() takes a file path and 
returns a single stylesheet with all @imports (that could be opened) included 
and in 
@media blocks where necessary. Afterwards, 
Minify_CSS_Linearizer::$includedFiles is 
an array of all files included (for change monitoring).

Original comment by mrclay....@gmail.com on 28 Aug 2008 at 5:56

GoogleCodeExporter commented 9 years ago
Hmm, linearize() needs to look out for files it's already included to avoid 
endless 
recursion.

Original comment by mrclay....@gmail.com on 28 Aug 2008 at 6:11

GoogleCodeExporter commented 9 years ago
Minify_Source would be better to have accessor functions rather than several 
public 
properties and a big magic constructor. This would ease subclassing.

Minify_ImportSource:
  private $_contents
  private $_includedFiles

  private function _linearize()
    run import processor
    cache file list and copy to $_includedFiles
    store css to $_contents

  function getContent() 
    if content not in $_contents
      _linearize()
    return $_contents

  function getLastModified()
    if not in cache
      _linearize()
    return max(filemtimes($_includedFiles))

Original comment by mrclay....@gmail.com on 26 Feb 2009 at 9:10

GoogleCodeExporter commented 9 years ago
Shelving until 2.1.2 is out.

Original comment by mrclay....@gmail.com on 26 Feb 2009 at 9:30

GoogleCodeExporter commented 9 years ago
Some feedback on such a feature:

1. It would be useful for me since the main reason i'm using Minify is that i 
want to
separate my CSS source code in several well organized files, which is a no-go 
for
production beyond 2-3 CSS files.

2. Right now i'm using the groups configuration to achieve this. It works 
fairly well.

3. For development, i have CSS files called profile-all.css or 
profile-admin.css (for
instance), which are stylesheets with only @import rules in them (plus 
occasionnal
documentation comments). So if i change a profile stylesheet, i have to 
replicate the
changes in groupsConfig.php; not a big deal, but if Minify can parse the CSS 
code to
use @import rules as an alternative to groups config (for CSS), it's even 
better.

Original comment by fverschelde on 26 Apr 2009 at 9:21

GoogleCodeExporter commented 9 years ago
Issue 223 has been merged into this issue.

Original comment by mrclay....@gmail.com on 2 Mar 2011 at 4:19

GoogleCodeExporter commented 9 years ago
I'm waiting for this too.
Is there a prevision to fix this issue?

Original comment by fael...@gmail.com on 25 Jun 2013 at 3:15

GoogleCodeExporter commented 9 years ago
I don't have time to implement this anytime soon. Since we already have groups 
the ROI just isn't there. Comment 3 has the overall plan.

Original comment by mrclay....@gmail.com on 25 Jun 2013 at 4:54