|
1 |
| -# Webpack-Encore plugin for Micro framework |
| 1 | +# Micro Framework |
2 | 2 |
|
3 |
| -[![Latest Version on Packagist][ico-version]][link-packagist] |
4 |
| -[![Software License][ico-license]](LICENSE.md) |
5 |
| -[![Total Downloads][ico-downloads]][link-downloads] |
6 |
| -[![Scrutinizer Code Quality][ico-scrutinizer-quality]][link-scrutinizer-quality] |
7 |
| -[![Code Coverage][ico-scrutinizer-coverage]][link-scrutinizer-coverage] |
8 |
| -[![Build Status][ico-scrutinizer-build]][link-scrutinizer-build] |
| 3 | +Documentation is available [here](https://micro-php.net/docs). If not, we will be grateful if you can become its author :) |
9 | 4 |
|
10 |
| -This plugin adds several twig functions that help to include script and style html tags to twig templates from webpack-encore entries. |
11 |
| - |
12 |
| -## Get started |
13 |
| - |
14 |
| -Before starting to work with the plugin, all you need is: |
15 |
| -* Project based on [Micro Framework][link-microframework]; |
16 |
| -* [@symfony/webpack-encore][link-symfony-webpack-encore] installed by npm or yarn; |
17 |
| - |
18 |
| -### Install |
19 |
| - |
20 |
| - You can install the plugin via composer: |
21 |
| -```bash |
22 |
| -composer require oleksiibulba/webpack-encore-plugin |
23 |
| -``` |
24 |
| - |
25 |
| -### Usage |
26 |
| - |
27 |
| -Add `OleksiiBulba\WebpackEncorePlugin\WebpackEncorePlugin` to your plugins list: |
28 |
| -```php |
29 |
| -<?php /* ./etc/plugins.php */ |
30 |
| - |
31 |
| -return [ |
32 |
| - // List of plugins: |
33 |
| - // ... |
34 |
| - OleksiiBulba\WebpackEncorePlugin\WebpackEncorePlugin::class, |
35 |
| - // ... |
36 |
| -]; |
37 |
| -``` |
38 |
| - |
39 |
| -To use the plugin you need to create an entrypoint in your webpack.config.js: |
40 |
| -```javascript |
41 |
| -/* ./webpack.config.js */ |
42 |
| -const Encore = require('@symfony/webpack-encore'); |
43 |
| -Encore |
44 |
| - /* ... */ |
45 |
| - .addEntry('your_entry_name', './path/to/your_entry_file.jsx') |
46 |
| - /* ... */ |
47 |
| -``` |
48 |
| - |
49 |
| -run build: |
50 |
| -```bash |
51 |
| -yarn dev |
52 |
| -// or |
53 |
| -npm dev |
54 |
| -``` |
55 |
| - |
56 |
| -and add one of the twig functions to a template: |
57 |
| -```html |
58 |
| -{# ./templates/base.html.twig #} |
59 |
| -{# ... #} |
60 |
| -<head> |
61 |
| - {{ encore_entry_script_tags('your_entry_name') }} |
62 |
| - {{ encore_entry_link_tags('your_entry_name') }} |
63 |
| -</head> |
64 |
| -{# ... #} |
65 |
| -``` |
66 |
| - |
67 |
| -Here is the signature of the twig functions: |
68 |
| -* encore_entry_script_tags | encore_entry_link_tags: |
69 |
| - * entryName, type: string, required; |
70 |
| - * extraAttributes, type: array, optional, default value: empty array; |
71 |
| -* getJavaScriptFiles | getCssFiles | entryExists: |
72 |
| - * entryName, type: string, required; |
73 |
| - |
74 |
| -If two or more entries contain common files, then they will be printed only once; |
75 |
| - |
76 |
| -#### Extra attributes |
77 |
| -To add extra attribute to the tags, you can pass them in the array as a second argument, like this: |
78 |
| -```html |
79 |
| -<head> |
80 |
| - {{ encore_entry_script_tags('your_entry_name', {'defer':true}) }} |
81 |
| -</head> |
82 |
| -``` |
83 |
| -and as a result, it will print next html (assuming your entrypoint 'app' contains only one file './js/app.js'): |
84 |
| -```html |
85 |
| -<head> |
86 |
| - <script href="/js/app.js" type="application/javascript" defer></script> |
87 |
| -</head> |
88 |
| -``` |
89 |
| - |
90 |
| -## Change Log |
91 |
| - |
92 |
| -Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. |
93 |
| - |
94 |
| -## Testing |
95 |
| - |
96 |
| -```bash |
97 |
| -composer test |
98 |
| -``` |
99 |
| - |
100 |
| -## Contributing |
101 |
| - |
102 |
| -Please feel free to open pull request or create an issue, they are more than welcome! |
103 |
| -Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md) for details. |
104 |
| - |
105 |
| -## Security |
106 |
| - |
107 |
| -If you discover any security related issues, please email [email protected] instead of using the issue tracker. |
108 |
| - |
109 |
| -## Credits |
110 |
| - |
111 |
| -- [Oleksii Bulba][link-author] |
112 |
| -- [Fabien Potencier][email-fabien] |
113 |
| -- [All Contributors][link-contributors] |
114 |
| - |
115 |
| -The code was taken and adapted from `symfony/webpack-encore-bundle` that was created by [Symfony Community ](https://symfony.com/contributors) and [Fabien Potencier ](mailto:[email protected]) in particular. |
116 |
| -Adapted for Micro framework plugin by [Oleksii Bulba][link-author]. |
117 |
| - |
118 |
| -For the full copyright and license information, please see the [License File](LICENSE.md) that was distributed with this source code. |
119 |
| - |
120 |
| -## License |
121 |
| - |
122 |
| -[The MIT License (MIT)][link-license]. Please see [License File](LICENSE.md) for more information. |
123 |
| - |
124 |
| -[ico-version]: https://img.shields.io/packagist/v/oleksiibulba/webpack-encore-plugin.svg?style=flat-square |
125 |
| -[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square |
126 |
| -[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/oleksiibulba/webpack-encore-plugin.svg?style=flat-square |
127 |
| -[ico-code-quality]: https://img.shields.io/scrutinizer/g/oleksiibulba/webpack-encore-plugin.svg?style=flat-square |
128 |
| -[ico-downloads]: https://img.shields.io/packagist/dt/oleksiibulba/webpack-encore-plugin.svg?style=flat-square |
129 |
| - |
130 |
| -[ico-scrutinizer-quality]: https://img.shields.io/scrutinizer/quality/g/OleksiiBulba/webpack-encore-plugin/master?style=flat-square |
131 |
| -[ico-scrutinizer-coverage]: https://img.shields.io/scrutinizer/coverage/g/OleksiiBulba/webpack-encore-plugin/master?style=flat-square |
132 |
| -[ico-scrutinizer-build]: https://img.shields.io/scrutinizer/build/g/OleksiiBulba/webpack-encore-plugin/master?style=flat-square |
133 |
| - |
134 |
| -[link-scrutinizer-quality]: https://scrutinizer-ci.com/g/OleksiiBulba/webpack-encore-plugin/?branch=master |
135 |
| -[link-scrutinizer-coverage]: https://scrutinizer-ci.com/g/OleksiiBulba/webpack-encore-plugin/?branch=master |
136 |
| -[link-scrutinizer-build]: https://scrutinizer-ci.com/g/OleksiiBulba/webpack-encore-plugin/build-status/master |
137 |
| - |
138 |
| -[link-microframework]: https://github.com/Micro-PHP/skeleton |
139 |
| -[link-symfony-webpack-encore]: https://www.npmjs.com/package/@symfony/webpack-encore |
140 |
| -[link-packagist]: https://packagist.org/packages/oleksiibulba/webpack-encore-plugin |
141 |
| -[link-travis]: https://travis-ci.org/oleksiibulba/webpack-encore-plugin |
142 |
| -[link-scrutinizer]: https://scrutinizer-ci.com/g/oleksiibulba/webpack-encore-plugin/code-structure |
143 |
| -[link-code-quality]: https://scrutinizer-ci.com/g/oleksiibulba/webpack-encore-plugin |
144 |
| -[link-downloads]: https://packagist.org/packages/oleksiibulba/webpack-encore-plugin |
145 |
| -[link-author]: https://github.com/OleksiiBulba |
146 |
| -[link-contributors]: ../../contributors |
147 |
| -[link-license]: https://opensource.org/licenses/MIT |
148 |
| -[email-fabien]: mailto:[email protected] |
| 5 | +Thanks to [Oleksii Bulba](https://github.com/OleksiiBulba) for implementing this plugin. |
0 commit comments