Skip to content

Commit 4f72211

Browse files
Misc doc tweaks and fixes (#9)
Thanks for publishing this nice bundle! I propose in this PR some tweaks in the docs for your consideration. Thanks.
1 parent 2374de6 commit 4f72211

File tree

2 files changed

+64
-58
lines changed

2 files changed

+64
-58
lines changed

README.md

Lines changed: 63 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212

1313
</div>
1414

15-
1615
<!-- ☘️ If you find this bundle helpful, feel free to show your appreciation by starring the repository on GitHub or
1716
sending a message to the author. Thank you! ☘️ -->
1817

19-
2018
## Minify integration
2119

2220
SensioLabs Minify Bundle integrates [Minify](https://github.com/tdewolff/minify) into Symfony Asset Mapper.
@@ -99,90 +97,97 @@ return [
9997
Depending on your deployment process, you might want to enable the
10098
bundle only in the desired environment(s).
10199

100+
## Usage
102101

103-
## Configuration
104-
105-
### AssetMapper Settings
106-
107-
#### Asset types
102+
If you use [AssetMapper][9], run the following command to minify all the assets:
108103

109-
```yaml
110-
# config/packages/sensiolabs_minify.yaml
111-
sensiolabs_minify:
112-
asset_mapper:
113-
114-
# Minify CSS and JS files
115-
types:
116-
css: true
117-
js: true
104+
```shell
105+
php bin/console asset-map:compile
118106
```
119107

120-
#### Exclude files
108+
This command is usually run when [serving assets in production][10] and the
109+
SensioLabs Minify Bundle will hook into it to minify all assets while copying them.
121110

122-
```yaml
123-
# config/packages/sensiolabs_minify.yaml
124-
sensiolabs_minify:
125-
asset_mapper:
111+
### Command Line
126112

127-
# Exclude files
128-
ignore_paths:
129-
- 'admin/*'
130-
- '*.min.js'
113+
You can also minify assets manually with the command line. First, make sure that
114+
the binary file used to minify assets is properly installed in your computer:
131115

132-
# Exclude vendor assets
133-
ignore_vendor: true
116+
```shell
117+
php bin/console minify:install
134118
```
135119

120+
Then, run the following command to minify assets:
136121

137-
### Minify Binary
122+
```shell
123+
# this outputs the result in the console
124+
php bin/console minify:assets css/main.css
138125

126+
# this will write the output into the 'main.min.css' file
127+
# (the given output file is created / overwritten if needed)
128+
php bin/console minify:assets css/main.css css/main.min.css
129+
```
139130

140-
#### Local binary
131+
## Configuration
132+
133+
### AssetMapper Settings
141134

142135
```yaml
143136
# config/packages/sensiolabs_minify.yaml
144137
sensiolabs_minify:
145-
minify:
146-
147-
# Auto-detect the local binary
148-
local_binary: 'auto'
149-
150-
# Specify the local binary path
151-
# local_binary: "/usr/local/sbin/minify"
152-
153-
# Or set false to disable
154-
# local_binary: false
138+
asset_mapper:
139+
# you can minify only CSS files, only JS files or both
140+
types:
141+
css: true # (default: true)
142+
js: true # (default: true)
143+
144+
# a list of assets to exclude from minfication (default: [])
145+
# the values of the list can be any shell wildcard patterns
146+
ignore_paths:
147+
- 'admin/*'
148+
- '*.min.js'
149+
150+
# whethere to exclude the assets stored in vendor/ from minification;
151+
# these assets are usually already minified, so it's common to ignore them
152+
ignore_vendor: true # (default: true)
155153
```
156154
157-
#### Automatic download
155+
### Minify Binary
156+
157+
The minification is performed by a binary file that can be installed on your
158+
computer/server or downloaded automatically by the bundle. This is the default
159+
configuration used by the bundle:
158160
159161
```yaml
160162
# config/packages/sensiolabs_minify.yaml
161163
sensiolabs_minify:
162-
minify:
164+
# ...
163165

164-
# Enable automatic download from GitHub
165-
download_binary: true
166+
minify:
167+
# this disables the usage of local binaries
168+
local_binary: false
166169

167-
# Directory to store the downloaded binary
168-
download_directory: '%kernel.project_dir%/var/minify'
170+
# if TRUE, the bundle will download the binary from GitHub
171+
download_binary: '%kernel.debug%'
169172

173+
# the local path where the downloaded binary is stored
174+
download_directory: '%kernel.project_dir%/var/minify'
170175
```
171176
172-
## Console
173-
174-
### Command Line
175-
176-
#### Install Minify locally
177+
You can customize this configuration to use a local binary:
177178
178-
```shell
179-
php bin/console minify:install
180-
```
179+
```yaml
180+
# config/packages/sensiolabs_minify.yaml
181+
sensiolabs_minify:
182+
# ...
181183

182-
#### Minify assets
184+
minify:
185+
# set it to 'auto' to let the bundle try to find the location of the binary
186+
local_binary: 'auto'
183187

184-
```shell
185-
php bin/console minify:assets css/main.css css/main.min.css
188+
# you can also define the path to the binary explicitly, but this won't work
189+
# if you run the application in multime servers with different binary locations
190+
local_binary: "/usr/local/sbin/minify"
186191
```
187192
188193
## Credits
@@ -208,7 +213,6 @@ Special thanks to the Symfony community for their contributions and feedback.
208213
209214
The [SensioLabs Minify Bundle](https://github.com/sensiolabs/minify-bundle) is released under the [MIT license](LICENSE).
210215
211-
212216
[1]: https://cdn.jsdelivr.net/npm/@tarekraafat/[email protected]/dist/autoComplete.js
213217
[3]: https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.js
214218
[5]: https://cdn.jsdelivr.net/npm/[email protected]/dist/video.js
@@ -217,3 +221,5 @@ The [SensioLabs Minify Bundle](https://github.com/sensiolabs/minify-bundle) is r
217221
[4]: https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.css
218222
[6]: https://cdn.jsdelivr.net/npm/[email protected]/dist/video-js.css
219223
[8]: https://github.com/w3c/w3c-website-templates-bundle/blob/main/public/dist/assets/styles/core.css
224+
[9]: https://symfony.com/doc/current/frontend/asset_mapper.html
225+
[10]: https://symfony.com/doc/current/frontend/asset_mapper.html#serving-assets-in-dev-vs-prod

src/Command/MinifyAssetCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ protected function configure(): void
6262
6363
<fg=bright-blue>INFORMATION</>
6464
If you're using AssetMapper, the assets will be minified automatically
65-
during the "<comment>asset-map:deploy</comment>" command.
65+
during the "<comment>asset-map:compile</comment>" command.
6666
EOF
6767
);
6868
}

0 commit comments

Comments
 (0)