johnkrovitch / sam-bundle
此包已被 废弃,不再维护。没有推荐替代包。
用于集成 Sam 库到 Symfony 的 Bundle
v0.2
2018-12-14 19:40 UTC
Requires
- php: ^7.0
- ext-pcntl: *
- johnkrovitch/sam: ^0.1
- symfony/config: ^3.0||^4.0
- symfony/console: ^3.0||^4.0
- symfony/dependency-injection: ^3.0||^4.0
- symfony/http-kernel: ^3.0||^4.0
- symfony/yaml: ^3.0||^4.0
Requires (Dev)
- phpunit/phpunit: ^6.0
This package is auto-updated.
Last update: 2021-06-05 15:05:45 UTC
README
SamBundle for Symfony。它会在 app/config 中使用配置来添加构建资产命令。SamBundle 使用 Sam 库(代表 Simple Asset Manager),允许您配置如何构建、压缩和合并您的资产。
简介
SamBundle 会读取一个 yaml 配置文件。该文件应包含一个任务列表。每个任务是一个源文件列表(js, css, scss...),应用于这些文件的过滤器列表,以及一个目标文件列表。
安装
composer require johnkrovitch/sam-bundle
配置
在 config.yml 中添加您的配置
jk_assets: # filters configuration filters: compass: # path to compass binary (if it is in $PATH, you could leave the default) bin: compass # activate merge, minify and copy filters merge: ~ minify: ~ copy: ~ tasks: # a task # main.css is just a name, you could put what ever you want, but each task should have a unique name main.css: # first will apply the Compass filter, then the merge filter, then we minify # the process should be as following : # 1) the Compass filter will only take the ".scss" files, and compile them to ".css" files. The ".scss" # files we be replaced by the ".css" files in the sources list # 2) the merge filter will take all the files in the sources list filters: - compass - merge - minify sources: - app/Resources/assets/sass/main.scss - vendor/components/bootstrap/css/bootstrap.min.css - vendor/components/bootstrap/css/bootstrap-theme.min.css - vendor/components/font-awesome/css/font-awesome.min.css - app/Resources/assets/css/hover-min.css destinations: - web/css/main.css fonts: filters: ~ sources: - vendor/components/bootstrap/fonts/ - vendor/components/font-awesome/fonts/ destinations: - web/fonts/ cms.js: filters: - merge - minify sources: - src/JK/CmsBundle/Resources/assets/js/jquery.iframe-transport.js - src/JK/CmsBundle/Resources/assets/js/cms/fileupload.js - vendor/blueimp/jquery-file-upload/js/jquery.fileupload.js destinations: - src/JK/CmsBundle/Resources/public/js/cms.js tinymce.css: filters: - compass - merge - minify sources: - src/JK/CmsBundle/Resources/assets/sass/tinymce.scss - web/css/custom-tinymce.css destinations: - src/JK/CmsBundle/Resources/public/css/tinymce.css
使用方法
配置好资产后,可以使用以下命令执行任务
bin/console jk:assets:build
在开发期间,您可以使用 watch 命令来监视配置的资产,并自动重新构建资产。
bin/console jk:assets:watch