Skip to content

Commit 1513e93

Browse files
committed
Chore: Readme
- Added more info to README.md file; Signed-off-by: Oleksii Bulba <[email protected]>
1 parent 9cfb9cc commit 1513e93

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,47 @@
22

33
This plugin adds several twig functions that help to include script and style html tags to twig templates from webpack-encore entries.
44

5+
## Get started
6+
7+
Before starting to work with the plugin, all you need is:
8+
* Project based on [Micro Framework](https://github.com/Micro-PHP/skeleton);
9+
* [@symfony/webpack-encore](https://www.npmjs.com/package/@symfony/webpack-encore) installed by npm or yarn;
10+
* Run composer command `composer require oleksiibulba/webpack-encore-plugin`;
11+
* Add `\Boo\WebpackEncorePlugin\WebpackEncorePlugin` to your plugins list;
12+
13+
## Usage
14+
15+
To use the plugin you need to create an entrypoint in your webpack.config.js, run build, and add one of the twig functions to a template:
16+
```html
17+
<head>
18+
{{ encore_entry_script_tags('your_entry_name') }}
19+
{{ encore_entry_link_tags('your_entry_name') }}
20+
</head>
21+
```
22+
23+
Here is the signature of the twig functions:
24+
* encore_entry_script_tags | encore_entry_link_tags:
25+
* entryName, type: string, required;
26+
* extraAttributes, type: array, optional, default value: empty array;
27+
* getJavaScriptFiles | getCssFiles | entryExists:
28+
* entryName, type: string, required;
29+
30+
If two or more entries contain common files, then they will be printed only once;
31+
32+
### Extra attributes
33+
To add extra attribute to the tags, you can pass them in the array as a second argument, like this:
34+
```html
35+
<head>
36+
{{ encore_entry_script_tags('your_entry_name', {'defer':true}) }}
37+
</head>
38+
```
39+
and as a result, it will print next html (assuming your entrypoint 'app' contains only one file './js/app.js'):
40+
```html
41+
<head>
42+
<script href="/js/app.js" type="application/javascript" defer></script>
43+
</head>
44+
```
45+
546
## Contributing
647

748
Please feel free to open pull request or create an issue, they are more than welcome!
@@ -14,4 +55,5 @@ Adapted for Micro framework plugin by Oleksii Bulba.
1455
For the full copyright and license information, please view the LICENSE file that was distributed with this source code.
1556

1657
## License
58+
1759
[MIT](https://opensource.org/licenses/MIT)

0 commit comments

Comments
 (0)