Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

This is a Micro-PHP plugin for webpack-encore support

License

NotificationsYou must be signed in to change notification settings

OleksiiBulba/webpack-encore-plugin

Repository files navigation

Latest Version on PackagistSoftware LicenseTotal DownloadsScrutinizer Code QualityCode CoverageBuild Status

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

Get started

Before starting to work with the plugin, all you need is:

Install

You can install the plugin via composer:

composer require oleksiibulba/webpack-encore-plugin

Usage

AddOleksiiBulba\WebpackEncorePlugin\WebpackEncorePlugin to your plugins list:

<?php/* ./etc/plugins.php */return [// List of plugins:// ...OleksiiBulba\WebpackEncorePlugin\WebpackEncorePlugin::class,// ...];

To use the plugin you need to create an entrypoint in your webpack.config.js:

/* ./webpack.config.js */constEncore=require('@symfony/webpack-encore');Encore/* ... */.addEntry('your_entry_name','./path/to/your_entry_file.jsx')/* ... */

run build:

yarn dev// ornpm dev

and add one of the twig functions to a template:

{# ./templates/base.html.twig #}{# ... #}<head>    {{ encore_entry_script_tags('your_entry_name') }}    {{ encore_entry_link_tags('your_entry_name') }}</head>{# ... #}

Here is the signature of the twig functions:

  • encore_entry_script_tags | encore_entry_link_tags:
    • entryName, type: string, required;
    • extraAttributes, type: array, optional, default value: empty array;
  • getJavaScriptFiles | getCssFiles | entryExists:
    • entryName, type: string, required;

If two or more entries contain common files, then they will be printed only once;

Extra attributes

To add extra attribute to the tags, you can pass them in the array as a second argument, like this:

<head>    {{ encore_entry_script_tags('your_entry_name', {'defer':true}) }}</head>

and as a result, it will print next html (assuming your entrypoint 'app' contains only one file './js/app.js'):

<head><scripthref="/js/app.js"type="application/javascript"defer></script></head>

Change Log

Please seeCHANGELOG for more information on what has changed recently.

Testing

composertest

Contributing

Please feel free to open pull request or create an issue, they are more than welcome!Please seeCONTRIBUTING andCODE_OF_CONDUCT for details.

Security

If you discover any security related issues, please emailoleksii_bulba@epam.com instead of using the issue tracker.

Credits

The code was taken and adapted fromsymfony/webpack-encore-bundle that was created bySymfony Community andFabien Potencier in particular.Adapted for Micro framework plugin byOleksii Bulba.

For the full copyright and license information, please see theLicense File that was distributed with this source code.

License

The MIT License (MIT). Please seeLicense File for more information.

About

This is a Micro-PHP plugin for webpack-encore support

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp