forked from BitBagCommerce/SyliusWishlistPlugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Webpack Encore (BitBagCommerce#77)
* Add webpack configuration * Replace gulp with webpack, add dist files * Update and relocate templates, refactor JS * Split readme.md into smaler files * Add plugin development documentation * Add frontend instructions * Upgrade frontend dependencies * Refactor a wishlist details page * Upgrade node version for githib actions * Change non-webpack.md * Improve QC and fix github actions * Add test attributes for Behat * Update docs * Improve QC * Improve QC
- Loading branch information
Showing
80 changed files
with
7,320 additions
and
368 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# BitBag SyliusWishlistPlugin | ||
|
||
- [⬅️ Back](../README.md#overview) | ||
- [➡️ Usage](./02-usage.md) | ||
|
||
## Installation | ||
|
||
|
||
1. *We work on stable, supported and up-to-date versions of packages. We recommend you to do the same.* | ||
|
||
```bash | ||
$ composer require bitbag/wishlist-plugin | ||
``` | ||
|
||
2. Add plugin dependencies to your `config/bundles.php` file: | ||
```php | ||
// config/bundles.php | ||
|
||
return [ | ||
... | ||
|
||
BitBag\SyliusWishlistPlugin\BitBagSyliusWishlistPlugin::class => ['all' => true], | ||
]; | ||
``` | ||
|
||
3. Import required config in your `config/packages/_sylius.yaml` file: | ||
```yaml | ||
# config/packages/_sylius.yaml | ||
|
||
imports: | ||
... | ||
|
||
- { resource: "@BitBagSyliusWishlistPlugin/Resources/config/config.yml" } | ||
``` | ||
4. Import routing in your `config/routes.yaml` file: | ||
|
||
```yaml | ||
# config/routes.yaml | ||
bitbag_sylius_wishlist_plugin: | ||
resource: "@BitBagSyliusWishlistPlugin/Resources/config/routing.yml" | ||
``` | ||
|
||
5. Update your database | ||
|
||
```bash | ||
$ bin/console doctrine:migrations:migrate | ||
``` | ||
|
||
**Note:** If you are running it on production, add the `-e prod` flag to this command. | ||
|
||
**Note:** If you are updating this plugin from version 1.4.x you need to run: | ||
|
||
```bash | ||
$ bin/console doctrine:migrations:version BitBag\\SyliusWishlistPlugin\\Migrations\\Version20201029161558 --add --no-interaction | ||
``` | ||
|
||
6. Add plugin assets to your project | ||
|
||
We recommend you to use Webpack (Encore), for which we have prepared four different instructions on how to add this plugin's assets to your project: | ||
|
||
- [Import webpack config](./01.1-webpack-config.md)* | ||
- [Add entry to existing config](./01.2-webpack-entry.md)) | ||
- [Import entries in your entry.js files](./01.3-import-entry.md)) | ||
- [Your own custom config](./01.4-custom-solution.md)) | ||
|
||
<small>* Default option for plugin development</small> | ||
|
||
|
||
However, if you are not using Webpack, here are instructions on how to add optimized and compressed assets directly to your project templates: | ||
|
||
- [Non webpack solution](./01.5-non-webpack.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# BitBag SyliusWishlistPlugin | ||
|
||
- [⬅️ Back](./01-installation.md) | ||
|
||
## Installation - Import Webpack Config | ||
|
||
- ✔️ Completely independent configuration | ||
- ✔️ No need to add plugin assets globally (you can add it to specific pages) | ||
|
||
<br> | ||
|
||
1. Import plugin's `webpack.config.js` file | ||
|
||
```js | ||
// webpack.config.js | ||
const [ bitbagWishlistShop, bitbagWishlistAdmin ] = require('./vendor/bitbag/wishlist-plugin/webpack.config.js') | ||
... | ||
|
||
module.exports = [..., bitbagWishlistShop, bitbagWishlistAdmin]; | ||
``` | ||
|
||
2. Add new packages in `./config/packages/assets.yaml` | ||
|
||
```yml | ||
# config/packages/assets.yaml | ||
|
||
framework: | ||
assets: | ||
packages: | ||
# ... | ||
wishlist_shop: | ||
json_manifest_path: '%kernel.project_dir%/public/build/bitbag/wishlist/shop/manifest.json' | ||
wishlist_admin: | ||
json_manifest_path: '%kernel.project_dir%/public/build/bitbag/wishlist/admin/manifest.json' | ||
``` | ||
3. Add new build paths in `./config/packages/webpack_encore.yml` | ||
|
||
```yml | ||
# config/packages/webpack_encore.yml | ||
webpack_encore: | ||
builds: | ||
# ... | ||
wishlist_shop: '%kernel.project_dir%/public/build/bitbag/wishlist/shop' | ||
wishlist_admin: '%kernel.project_dir%/public/build/bitbag/wishlist/admin' | ||
``` | ||
|
||
4. Add encore functions to your templates | ||
|
||
```twig | ||
{# @SyliusShopBundle/_scripts.html.twig #} | ||
{{ encore_entry_script_tags('bitbag-wishlist-shop', null, 'wishlist_shop') }} | ||
{# @SyliusShopBundle/_styles.html.twig #} | ||
{{ encore_entry_link_tags('bitbag-wishlist-shop', null, 'wishlist_shop') }} | ||
{# @SyliusAdminBundle/_scripts.html.twig #} | ||
{{ encore_entry_script_tags('bitbag-wishlist-admin', null, 'wishlist_admin') }} | ||
{# @SyliusAdminBundle/_styles.html.twig #} | ||
{{ encore_entry_link_tags('bitbag-wishlist-admin', null, 'wishlist_admin') }} | ||
``` | ||
|
||
5. Run `yarn encore dev` or `yarn encore production` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# BitBag SyliusWishlistPlugin | ||
|
||
- [⬅️ Back](./01-installation.md) | ||
|
||
## Installation - Add new entry to existing configs | ||
|
||
- ✔️ Same webpack configuration for plugin and project assets | ||
- ✔️ No need to add plugin assets globally (you can add it to specific pages) | ||
|
||
<br> | ||
|
||
1. Add new entries to your `webpack.config.js` | ||
```js | ||
// ./webpack.config.js | ||
|
||
// Shop config | ||
.addEntry('bitbag-wishlist-shop', 'vendor/bitbag/wishlist-plugin/src/Resources/assets/shop/entry.js') | ||
|
||
// Admin config | ||
.addEntry('bitbag-wishlist-admin', 'vendor/bitbag/wishlist-plugin/src/Resources/assets/admin/entry.js') | ||
``` | ||
|
||
2. Add encore functions to your templates | ||
|
||
```twig | ||
{# @SyliusShopBundle/_scripts.html.twig #} | ||
{{ encore_entry_script_tags('bitbag-wishlist-shop', null, 'shop') }} | ||
{# @SyliusShopBundle/_styles.html.twig #} | ||
{{ encore_entry_link_tags('bitbag-wishlist-shop', null, 'shop') }} | ||
{# @SyliusAdminBundle/_scripts.html.twig #} | ||
{{ encore_entry_script_tags('bitbag-wishlist-admin', null, 'admin') }} | ||
{# @SyliusAdminBundle/_styles.html.twig #} | ||
{{ encore_entry_link_tags('bitbag-wishlist-admin', null, 'admin') }} | ||
``` | ||
|
||
3. Run `yarn encore dev` or `yarn encore production` |
Oops, something went wrong.