symfony2 assetics yui compressor on windows (path syntax)

后端 未结 3 594
生来不讨喜
生来不讨喜 2021-01-03 12:02

I\'m trying to get assetics running with the yui compressor and, if this is running, sass. Right now, both don\'t work. When removing all filters from config.yml and the twi

相关标签:
3条回答
  • 2021-01-03 12:50

    For other users who use window server 2008 r2 :

    1. Maybe you should change the C:\windows\Temp folder property to 777 (read/write) for the IIS user / or the machine's normal user

    2. please unpack the ruby.7z from rubyinstaller.org , and go to C:\_ruby193\bin , in this unpack position you should exec the CMD prompt , type :

      ruby -S gem install sass
      

      so that you will get the sass.bat in that position

    3. It's time to use Boo's best answer , and please notice that in symfony2 dev env maybe it's not necessary to change the use_controller to false (in the config.yml) , because there's another use_controller in the config_dev.yml (set to true) , and in routing_dev.yml there's also a _assetic router , they're perhaps associated.

    0 讨论(0)
  • 2021-01-03 12:58

    Ok, I figured it out. Man, this one was brutal.

    Let's start with the easy stuff. A working version of the config.yml can look like this:

    assetic:
      debug: false
      use_controller: false
      java: C:\Program Files (x86)\Java\jre6\bin\java.exe
      sass: C:\Program Files (x86)\Ruby192\bin\sass.bat
      filters:
        scss: ~
        yui_js:
          jar: %kernel.root_dir%\Resources\java\yuicompressor-2.4.6.jar
    

    For some reason, assetic is always importing a whole directory for scss, so I had to make a combine.scss which imports the other scss files in the correct order.

    And now it gets ugly, as one have to change the assetics core in order to get this working. The developers of assetic know this bug and I think it is fixed in some development trunk/branch but not the stable one.

    The Assetic\Util\ProcessBuilder has to be changed on line 95

    if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
    

    ,line 103

    $script .= ' '.implode(' ', array_map('escapeshellarg', $args));
    

    and line 110

    return new Process($script, $this->cwd, null, $this->stdin, $this->timeout, $options);
    

    I hope this bug get fixed soon and till then anybody trying to get it working finds this thread... Took me like 8 hours of debuging, reading and trying different approaches.

    0 讨论(0)
  • 2021-01-03 13:00

    Answer by Boo Nov 19 at 22:53 did work for me by changing everything he mentioned in Assetic\Util\ProcessBuilder (I ignored line 95 as it looks the same as in my file)

    Now it works on windows. Thanks!

    Just to confirm. Im using Symfony 2.0.7 and yuicompressor-2.4.7

    0 讨论(0)
提交回复
热议问题