Skip to content

Commit 11f9b48

Browse files
committed
Pre release
1 parent 5f5a267 commit 11f9b48

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2409
-1
lines changed

.gitattributes

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/.editorconfig export-ignore
2+
/.git* export-ignore
3+
/.php-cs-fixer.dist.php export-ignore
4+
/doc/ export-ignore
5+
/tests/ export-ignore
6+
/phpunit.dist.xml export-ignore
7+
/phpstan.dist.neon export-ignore

.github/workflows/CI.yaml

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
name: "CI"
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
15+
dep:
16+
name: "Dependencies"
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: "Git: checkout"
20+
uses: actions/checkout@v4
21+
- name: "PHP: setup 8.3 "
22+
uses: shivammathur/setup-php@v2
23+
with:
24+
php-version: '8.3'
25+
coverage: none
26+
tools: composer
27+
- name: "Composer: cache config"
28+
id: composer-cache
29+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
30+
- name: "Composer: cache restore"
31+
uses: actions/cache@v4
32+
with:
33+
path: ${{ steps.composer-cache.outputs.dir }}
34+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
35+
restore-keys: ${{ runner.os }}-composer-
36+
- name: "Composer: validate"
37+
run: composer validate --strict
38+
- name: "Composer: install"
39+
run: composer install --prefer-dist --no-progress --no-suggest
40+
- name: "Composer: audit"
41+
run: composer audit
42+
43+
cs:
44+
name: "Code style"
45+
runs-on: ubuntu-latest
46+
steps:
47+
- name: "Git: checkout"
48+
uses: actions/checkout@v4
49+
- name: "PHP: setup 8.3"
50+
uses: shivammathur/setup-php@v2
51+
with:
52+
php-version: '8.3'
53+
coverage: none
54+
tools: php-cs-fixer
55+
- name: "Php-CS-Fixer: version"
56+
run: php-cs-fixer -V
57+
- name: "Php-CS-Fixer: check"
58+
run: php-cs-fixer check --diff
59+
60+
sa:
61+
name: "Static Analysis"
62+
runs-on: ubuntu-latest
63+
steps:
64+
- name: "Git: checkout"
65+
uses: actions/checkout@v4
66+
- name: "PHP: setup ${{ matrix.php-version }}"
67+
uses: shivammathur/setup-php@v2
68+
with:
69+
php-version: '8.3'
70+
coverage: none
71+
tools: phpstan
72+
- name: "Composer: cache config"
73+
id: composer-cache
74+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
75+
- name: "Composer: cache restore"
76+
uses: actions/cache@v4
77+
with:
78+
path: ${{ steps.composer-cache.outputs.dir }}
79+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
80+
restore-keys: ${{ runner.os }}-composer-
81+
- name: "Composer: validate"
82+
run: composer validate --strict
83+
- name: "Composer: install"
84+
run: composer install --prefer-dist --no-progress --no-suggest
85+
- name: "PHPStan: version"
86+
run: phpstan --version
87+
- name: "PHPStan: analyse"
88+
run: phpstan analyse src/
89+
90+
tests:
91+
name: "Tests (PHP ${{ matrix.php-version }})"
92+
runs-on: ubuntu-latest
93+
strategy:
94+
matrix:
95+
php-version:
96+
- '8.2'
97+
- '8.3'
98+
fail-fast: false
99+
steps:
100+
- name: "Git: Checkout"
101+
uses: actions/checkout@v4
102+
- name: "PHP: setup ${{ matrix.php-version }}"
103+
uses: shivammathur/setup-php@v2
104+
with:
105+
php-version: ${{ matrix.php-version }}
106+
coverage: xdebug
107+
ini-values: xdebug.mode=coverage
108+
- name: "PHP: php matcher"
109+
run: |
110+
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
111+
- name: "Composer: cache config"
112+
id: composer-cache
113+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
114+
- name: "Composer: cache restore"
115+
uses: actions/cache@v4
116+
with:
117+
path: ${{ steps.composer-cache.outputs.dir }}
118+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
119+
restore-keys: ${{ runner.os }}-composer-
120+
- name: "Composer: validate"
121+
run: composer validate --strict
122+
- name: "Composer: install"
123+
run: composer install --prefer-dist --no-progress --no-suggest
124+
- name: "PHPUnit: version"
125+
run: php vendor/bin/phpunit --version
126+
- name: "PHPUnit: tests"
127+
run: php vendor/bin/phpunit
128+
# - name: "Codecov: upload"
129+
# uses: codecov/codecov-action@v4.0.1
130+
# with:
131+
# token: ${{ secrets.CODECOV_TOKEN }}

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/.phpunit.cache
2+
/.php-cs-fixer.cache
3+
/composer.lock
4+
/phpunit.xml
5+
/tests/Fixtures/var/
6+
/vendor/

.php-cs-fixer.dist.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
$licence = <<<'EOF'
4+
This file is part of the SensioLabs MinifyBundle package.
5+
6+
(c) Simon André - Sensiolabs
7+
8+
For the full copyright and license information, please view the LICENSE
9+
file that was distributed with this source code.
10+
EOF;
11+
12+
$finder = (new PhpCsFixer\Finder())
13+
->in(__DIR__)
14+
->exclude('tests/Fixtures/var')
15+
;
16+
17+
return (new PhpCsFixer\Config())
18+
->setRiskyAllowed(true)
19+
->setRules([
20+
'@PSR12' => true,
21+
'declare_strict_types' => true,
22+
'header_comment' => ['header' => $licence],
23+
])
24+
->setFinder($finder)
25+
;

.symfony.bundle.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
branches: ["main"]
2+
maintained_branches: ["main"]
3+
doc_dir: "doc"

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# CHANGELOG
2+
3+
## 0.9.0
4+
5+
- First version of the bundle

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2024 SensioLabs
3+
Copyright (c) 2024-present Simon André & SensioLabs
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
<picture>
2+
<source media="(prefers-color-scheme: light)" srcset="./minify.svg" />
3+
<img src="./minify.dark.svg" alt="SensioLabs MinifyBundle for Symfony" width="100%" />
4+
</picture>
5+
6+
<div align="center">
7+
8+
[![PHP Version](https://img.shields.io/badge/%C2%A0php-%3E%3D%208.3-777BB4.svg?logo=php&logoColor=white)](https://github.com/sensiolabs/minify-bundle/blob/main/composer.json)
9+
[![CI](https://github.com/sensiolabs/minify-bundle/actions/workflows/CI.yaml/badge.svg)](https://github.com/sensiolabs/minify-bundle/actions)
10+
[![Release](https://img.shields.io/github/v/release/sensiolabs/minify-bundle)](https://github.com/sensiolabs/minify-bundle/releases)
11+
[![License](https://img.shields.io/github/license/sensiolabs/minify-bundle?color=82E83F)](https://github.com/sensiolabs/minify-bundle/blob/main/LICENSE)
12+
13+
</div>
14+
15+
<h1 align="center">SensioLabs Minify Bundle</h1>
16+
17+
## Minify integration
18+
19+
SensioLabs Minify Bundle integrates [Minify](https://github.com/tdewolff/minify) into Symfony Asset Mapper.
20+
21+
### Asset Minifier
22+
23+
✅ Minify `CSS` and `JS` files, remove whitespace, comments, and more..
24+
25+
🌍🌍 Reduces the size of your assets by up to `70%` (see metrics below).
26+
27+
🚀🚀🚀 Improves the loading time of your website, and the `user experience`.
28+
29+
### Asset Mapper
30+
31+
🎯 Automatically `minify` assets during the build process.
32+
33+
📦📦 Compress and store minified assets in the `cache` directory.
34+
35+
🌿🌿🌿 Download the Minify binary `automatically` from the repository.
36+
37+
## Minification
38+
39+
### JavaScript
40+
41+
| Asset | Before | After | Diff | Compression | Time |
42+
|------------------------|-------:|-------:|-----:|------------------------------------------|------:|
43+
| [Autocomplete.js][1] | 20 kB | 9.2 kB | -54% | ⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩 | 8 ms |
44+
| [Bootstrap.js][3] | 145 kB | 62 kB | -57% | ⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩 | 10 ms |
45+
| [Video.js][5] | 2.3 MB | 0.7 MB | -71% | ⬜️⬜️⬜️⬜️⬜️⬜️🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩 | 42 ms |
46+
| [w3c.org js][7] | 44 kB | 19 kB | -57% | ⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩 | 6 ms |
47+
48+
49+
### CSS
50+
51+
| Asset | Before | After | Diff | Compression | Time |
52+
|-----------------------|-------:|-------:|-----:|-------------------------------------------|-----:|
53+
| [Autocomplete.css][2] | 3.1 kB | 2.5 kB | -19% | ⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️🟩🟩🟩🟩🟩 | 2 ms |
54+
| [Bootstrap.css][4] | 281 kB | 232 kB | -18% | ⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️🟩🟩🟩🟩 | 9 ms |
55+
| [Video-js.css][6] | 53 kB | 47 kB | -12% | ⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜⬜️⬜️⬜️⬜️⬜️⬜️⬜️️🟩🟩 | 4 ms |
56+
| [w3c.org css][8] | 111 kB | 70 kB | -37% | ⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️🟩🟩🟩🟩🟩🟩🟩🟩 | 5 ms |
57+
58+
59+
## Installation
60+
61+
Make sure Composer is installed globally, as explained in the
62+
[installation chapter](https://getcomposer.org/doc/00-intro.md)
63+
of the Composer documentation.
64+
65+
### With Symfony Flex
66+
67+
Open a command console, enter your project directory and execute:
68+
69+
```shell
70+
composer require sensiolabs/minify-bundle
71+
```
72+
73+
### Without Symfony Flex
74+
75+
#### Step 1: Download the Bundle
76+
77+
Open a command console, enter your project directory and execute the
78+
following command to download the latest stable version of this bundle:
79+
80+
```shell
81+
composer require sensiolabs/minify-bundle
82+
```
83+
84+
#### Step 2: Enable the Bundle
85+
86+
Then, enable the bundle by adding it to the list of registered bundles
87+
in the `config/bundles.php` file of your project:
88+
89+
```php
90+
// config/bundles.php
91+
92+
return [
93+
// ...
94+
Sensiolabs\MinifyBundle\SensiolabsMinifyBundle::class => ['all' => true],
95+
];
96+
```
97+
98+
Depending on your deployment process, you might want to enable the
99+
bundle only in the desired environment(s).
100+
101+
102+
## Configuration
103+
104+
### AssetMapper Settings
105+
106+
#### Asset types
107+
108+
```yaml
109+
# config/packages/sensiolabs_minify.yaml
110+
sensiolabs_minify:
111+
asset_mapper:
112+
113+
# Minify CSS and JS files
114+
types:
115+
css: true
116+
js: true
117+
```
118+
119+
#### Exclude files
120+
121+
```yaml
122+
# config/packages/sensiolabs_minify.yaml
123+
sensiolabs_minify:
124+
asset_mapper:
125+
126+
# Exclude files
127+
ignore_paths:
128+
- 'admin/*'
129+
- '*.min.js'
130+
131+
# Exclude vendor assets
132+
ignore_vendor: true
133+
```
134+
135+
136+
### Minify Binary
137+
138+
139+
#### Local binary
140+
141+
```yaml
142+
# config/packages/sensiolabs_minify.yaml
143+
sensiolabs_minify:
144+
minify:
145+
146+
# Auto-detect the local binary
147+
local_binary: 'auto'
148+
149+
# Specify the local binary path
150+
# local_binary: "/usr/local/sbin/minify"
151+
152+
# Or set false to disable
153+
# local_binary: false
154+
```
155+
156+
#### Automatic download
157+
158+
```yaml
159+
# config/packages/sensiolabs_minify.yaml
160+
sensiolabs_minify:
161+
minify:
162+
163+
# Enable automatic download from GitHub
164+
download_binary: true
165+
166+
# Directory to store the downloaded binary
167+
download_directory: '%kernel.project_dir%/var/minify'
168+
169+
```
170+
171+
## Console
172+
173+
### Command Line
174+
175+
#### Install Minify locally
176+
177+
```shell
178+
php bin/console minify:install
179+
```
180+
181+
#### Minify assets
182+
183+
```shell
184+
php bin/console minify:assets css/main.css css/main.min.css
185+
```
186+
187+
## Credits
188+
189+
- Minify binary: [Timo Dewolf](https://github.com/tdewolff)
190+
- Symfony Bundle: [Simon André](https://github.com/smnandre) & [SensioLabs](https://github.com/sensiolabs)
191+
192+
## License
193+
194+
The [SensioLabs Minify Bundle](https://github.com/sensiolabs/minify-bundle) is released under the [MIT license](LICENSE).
195+
196+
197+
[1]: https://cdn.jsdelivr.net/npm/@tarekraafat/autocomplete.js@10.2.7/dist/autoComplete.js
198+
[3]: https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.js
199+
[5]: https://cdn.jsdelivr.net/npm/video.js@8.18.1/dist/video.js
200+
[7]: https://github.com/w3c/w3c-website-templates-bundle/blob/main/public/dist/assets/js/main.js
201+
[2]: https://cdn.jsdelivr.net/npm/@tarekraafat/autocomplete.js@10.2.7/dist/css/autoComplete.css
202+
[4]: https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.css
203+
[6]: https://cdn.jsdelivr.net/npm/video.js@8.18.1/dist/video-js.css
204+
[8]: https://github.com/w3c/w3c-website-templates-bundle/blob/main/public/dist/assets/styles/core.css

0 commit comments

Comments
 (0)