定制 flazzarotto/sass-generator 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

flazzarotto/sass-generator

Composer 安装命令:

composer require flazzarotto/sass-generator

包简介

CSS and Sourcemaps SCSS compiler service and command for Symfony3

README 文档

README

This Symfony3 bundle use leafo/scssphp and koala-framework/sourcemaps to compile all scss files of a directory to css in another directory. You can also generate css sourcemaps as well. It is mainly made up of a sass compiler / sourcemap generator service and a command line tool.

## Set up

  1. Run composer require flazzarotto/sass-generator dev-master

  2. Modify you AppKernel.php:

    $bundles = [
      // bunch of other bundles
      new Flazzarotto\SassGeneratorBundle\SassGeneratorBundle(), // <= add this line
    ];
  3. (Optional) You can automatise the sass generation by adding commands to your composer.json in scripts > post-install-cmd/post-update-cmd/warmup. See below for more details about sass generator service and its command line tool.

HOW TO USE

The main goal of this package is to generate compiled css files and associated sourcemaps from a list of scss files in a symfony3 project. This can be very useful if your project must be released on cloud services such as Heroku. There are to ways to use it :

  1. command line: php bin/console sass:generate [inputFolder:outputFolder] [--source-maps] [--line-numbers] [--precision x] [--format myFormat]

    • inputFolder:outputFolder : should be something like "web/[...]scssInputFolder:web/[...]cssOutputFolder" - default value : web/scss:web/css
    • source-maps : if set it will generate source maps as well (same folder as css files)
    • line-number : will generate CSS with source file line numbers
    • precision : set the precision for float numbers (default sass value is 5)
    • format : the format wanted in the following: compact, compressed, crunched, expanded, nested

    Examples:

    • php bin/console sass:generate web/scss:web/css --source-maps will generate both compacted css and sourcemap files
    • php bin/console sass:generate web/scss:web/css --line-numbers will generate only css commented with original sass line numbers in comments (can't be used with compressed or crunched formats)
    • php bin/console sass:generate web/scss:web/css --format compressed will generate only minified css (can't work with source-maps option)
  2. Service

    You can use this service if you need to be more flexible than the command tool line or if you intend to create your own command. Here's how to initialise the service:

    // get the service inside a controller
    $sassGenerator = $this->get('sass_generator');
    
    $sassGenerator->init($sourceMaps, $lineNumbers, $precision, $format, "inputFolder:outputFolder");

    Parameters are the same as the command line tool (set options to true to get same result). Then you will be able to use the following methods:

    // generate css files in output folder from all scss files found in input folder.
    $sassGenerator->compileAll();
    
    // get all scss files found in folder
    $files = $sassGenerator->getSourceFiles();
    
    // compile only one file in css
    $sassGenerator->compile($file[0]); // false on failure, path to css file on success
    
    // compile only one file in sourcemap - css must have been generated before 
    $sassGenerator->generateMap($file[0]); // false on failure, path to sourcemap file on success
    
    // get all warnings encountered during compilation or sourcemap generation
    $sassGenerator->getWarnings(); 
    
    // you can re-initialise the service at any time to compile another scss folder
    $sassGenerator->init(/*params*/); 

统计信息

  • 总下载量: 49
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0
  • 更新时间: 2016-11-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固