Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/encore-webpack #5461

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
a423069
moved assets to webpack
Feb 2, 2019
2ac1b4d
added import select2 locales and momentjs locales, asset splitting , …
Feb 3, 2019
aae7f8c
fixed jquery
Feb 3, 2019
74bb9bb
optimized Makefile
Feb 3, 2019
01bfa9f
added whitespace in Makefile
Feb 3, 2019
4d35e1e
allow override YARN env
Feb 3, 2019
f81caab
removed configuration part for assets
Feb 3, 2019
724a137
ensure yarn installs run before build
Feb 3, 2019
f3a26c6
fixed make target
Feb 4, 2019
1657aff
added user flag in makefile
Feb 5, 2019
d7fe4f8
fixed bootstrap datetime picker => downgraded jQuery
Feb 5, 2019
e020df7
removed tests for assets
Feb 5, 2019
0388fbc
fixed tests, removed unused mergeArray function, reverted package.json
Feb 5, 2019
76231c5
removed bower.json, removed .gitignore lines
Feb 5, 2019
ec7a504
moved dependencies
Mar 11, 2019
8244686
added compiler pass to provide webpack.builds parameters as twig global
Jul 24, 2019
fc9d415
added test for compiler pass
Jul 24, 2019
80296d7
fixed tests, used webpack addAliases
Jul 24, 2019
b400461
fixed test
Jul 24, 2019
e765719
cs fixes
Jul 24, 2019
1d98fe7
updated docs
Jul 24, 2019
e91ab80
updated docs
Jul 25, 2019
5cbe673
added upgrade note, fixed typo
Jul 25, 2019
43750a5
removed blankline
Jul 26, 2019
922108b
renamed global entries
Jul 26, 2019
a976f3c
Update docs/getting_started/installation.rst
Jul 29, 2019
700eebb
Update docs/getting_started/installation.rst
Jul 29, 2019
3ba5335
fixed async loading of select2 language file
Jul 29, 2019
cba333d
raised webpack-encore-bundle requirement
Jul 29, 2019
b36c911
remove twig function localize_for_moment
Jul 29, 2019
4a0df3f
removed twig function localize_for_select2
Jul 29, 2019
6f35778
Update docs/getting_started/installation.rst
Aug 6, 2019
2136474
revert twig extension, test, and used canonicalize functions in twig …
Jan 16, 2020
86a5ba9
cs fix
Jan 16, 2020
652fc7d
removed registerFormMapping
Jan 17, 2020
106c02d
cs fix
Jan 17, 2020
6ac286f
registered WebpackEncoreBundle
Jan 17, 2020
c5fa544
cs fix
Feb 1, 2020
225b5a9
removed webpack chunk splitting
Feb 1, 2020
de84bef
added yarn build for travis
Feb 1, 2020
5983158
fixed Docs
Feb 1, 2020
02eea2d
Merge branch 'master' into feature/encore-webpack
Feb 10, 2020
eada567
Update tests/DependencyInjection/Compiler/WebpackEntriesCompilerPassT…
Feb 17, 2020
678e024
Update docs/getting_started/installation.rst
Feb 17, 2020
36f0f0d
Update src/DependencyInjection/Compiler/WebpackEntriesCompilerPass.php
Feb 17, 2020
8780d09
Update src/DependencyInjection/Compiler/WebpackEntriesCompilerPass.php
Feb 18, 2020
fc4727b
Merge branch 'master' into feature/encore-webpack
Mar 1, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
59 changes: 1 addition & 58 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,61 +11,4 @@ phpstan.neon
/.phpunit.result.cache
/docs/_build/

# clean up some non bower ready package
src/Resources/public/vendor/admin-lte/bootstrap
src/Resources/public/vendor/admin-lte/build
src/Resources/public/vendor/admin-lte/dist/img
!src/Resources/public/vendor/admin-lte/dist/img/boxed-bg.jpg # Only image called in AdminLTe.css
src/Resources/public/vendor/admin-lte/dist/js/app.js
src/Resources/public/vendor/admin-lte/dist/js/demo.js
src/Resources/public/vendor/admin-lte/dist/js/pages
src/Resources/public/vendor/admin-lte/documentation
src/Resources/public/vendor/admin-lte/pages
src/Resources/public/vendor/admin-lte/plugins
src/Resources/public/vendor/admin-lte/*.html
src/Resources/public/vendor/admin-lte/Gruntfile.js

src/Resources/public/vendor/iCheck/skins/all.css
src/Resources/public/vendor/iCheck/skins/*/*
!src/Resources/public/vendor/iCheck/skins/square/blue.css
!src/Resources/public/vendor/iCheck/skins/square/blue.png
!src/Resources/public/vendor/iCheck/skins/square/[email protected]
src/Resources/public/vendor/iCheck/icheck.js

src/Resources/public/vendor/slimScroll/examples
src/Resources/public/vendor/slimScroll/jquery.slimscroll.js

src/Resources/public/vendor/bootstrap/grunt
src/Resources/public/vendor/bootstrap/less
src/Resources/public/vendor/bootstrap/test-infra
src/Resources/public/vendor/bootstrap/Gruntfile.js

src/Resources/public/vendor/jqueryui/themes/black-tie
src/Resources/public/vendor/jqueryui/themes/blitzer
src/Resources/public/vendor/jqueryui/themes/cupertino
src/Resources/public/vendor/jqueryui/themes/dark-hive
src/Resources/public/vendor/jqueryui/themes/dot-luv
src/Resources/public/vendor/jqueryui/themes/eggplant
src/Resources/public/vendor/jqueryui/themes/excite-bike
src/Resources/public/vendor/jqueryui/themes/hot-sneaks
src/Resources/public/vendor/jqueryui/themes/humanity
src/Resources/public/vendor/jqueryui/themes/le-frog
src/Resources/public/vendor/jqueryui/themes/mint-choc
src/Resources/public/vendor/jqueryui/themes/overcast
src/Resources/public/vendor/jqueryui/themes/pepper-grinder
src/Resources/public/vendor/jqueryui/themes/redmond
src/Resources/public/vendor/jqueryui/themes/smoothness
src/Resources/public/vendor/jqueryui/themes/south-street
src/Resources/public/vendor/jqueryui/themes/start
src/Resources/public/vendor/jqueryui/themes/sunny
src/Resources/public/vendor/jqueryui/themes/swanky-purse
src/Resources/public/vendor/jqueryui/themes/trontastic
src/Resources/public/vendor/jqueryui/themes/ui-darkness
src/Resources/public/vendor/jqueryui/themes/ui-lightness
src/Resources/public/vendor/jqueryui/themes/vader

src/Resources/public/vendor/jquery/src

src/Resources/public/vendor/jquery.scrollTo/demo
src/Resources/public/vendor/jquery.scrollTo/tests

node_modules/
2 changes: 2 additions & 0 deletions .travis/install_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ wget https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coverall
chmod u+x "${HOME}/bin/coveralls"

composer update --prefer-dist --no-interaction --prefer-stable ${COMPOSER_FLAGS}

make yarn-build
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,19 @@ endif
docs:
cd docs && sphinx-build -W -b html -d _build/doctrees . _build/html
.PHONY: docs

YARN ?= @docker run --rm -it -v ${PWD}:/usr/src/app -w /usr/src/app node:11-alpine yarn
silasjoisten marked this conversation as resolved.
Show resolved Hide resolved
yarn-install:
${YARN} install
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add .PHONY to the non-file creating commands

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does that mean?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TLDR: Phony does not check for file existence when you run make

https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you i will do that


yarn-watch:
${YARN} watch

yarn.lock:
$(MAKE) yarn-install

node_modules: yarn.lock
$(MAKE) yarn-install

yarn-build: yarn.lock node_modules
${YARN} build
14 changes: 13 additions & 1 deletion UPGRADE-4.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,16 @@ The Twig filters that come with the bundle will no longer load a default templat
The `sonata_admin` twig extension is now final. You may no longer extend it.

## SimplePager
Method `SimplePager::getResults` is always returning an array
Method `SimplePager::getResults` is always returning an array

## WebpackEncoreBundle

In `config/sonata_admin.yaml` the complete `assets:` section was removed and is no longer available.

Execute `bin/console assets:install` and add following to the `config/sonata_admin.yaml` file:

```yaml
webpack_encore:
builds:
sonata_admin: '%kernel.project_dir%/public/bundles/sonataadmin/dist'
```
24 changes: 0 additions & 24 deletions bower.json

This file was deleted.

1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"symfony/twig-bridge": "^4.3",
"symfony/twig-bundle": "^4.3",
"symfony/validator": "^4.3",
"symfony/webpack-encore-bundle": "^1.6",
"twig/extensions": "^1.5",
"twig/twig": "^2.12"
},
Expand Down
16 changes: 16 additions & 0 deletions docs/getting_started/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,22 @@ install the assets:
bin/console cache:clear
bin/console assets:install

Webpack Encore Integration
--------------------------

When the assets are installed add following to your configuration:

.. code-block:: yaml

silasjoisten marked this conversation as resolved.
Show resolved Hide resolved
# config/sonata_admin.yaml
core23 marked this conversation as resolved.
Show resolved Hide resolved

webpack_encore:
builds:
sonata_admin: '%kernel.project_dir%/public/bundles/sonataadmin/dist'
# Handling multiple entry points. For example app entry
#app: '%kernel.project_dir%/public/build'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am for removing the comments

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we explain to someone who already has webpack? than he needs to do that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why? he already has an entry with app: ... in another file and the get merged, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not because he uses the assets config section in sonata_admin.yaml



silasjoisten marked this conversation as resolved.
Show resolved Hide resolved
The Admin Interface
-------------------

Expand Down
56 changes: 0 additions & 56 deletions docs/reference/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -172,62 +172,6 @@ Full Configuration Options
pager_results: '@SonataAdmin/Pager/results.html.twig'
tab_menu_template: '@SonataAdmin/Core/tab_menu_template.html.twig'
knp_menu_template: '@SonataAdmin/Menu/sonata_menu.html.twig'
assets:
stylesheets:

# The default stylesheet list:
- bundles/sonatacore/vendor/bootstrap/dist/css/bootstrap.min.css
- bundles/sonatacore/vendor/components-font-awesome/css/font-awesome.min.css
- bundles/sonatacore/vendor/ionicons/css/ionicons.min.css
- bundles/sonataadmin/vendor/admin-lte/dist/css/AdminLTE.min.css
- bundles/sonataadmin/vendor/admin-lte/dist/css/skins/skin-black.min.css
- bundles/sonataadmin/vendor/iCheck/skins/square/blue.css
- bundles/sonatacore/vendor/eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css
- bundles/sonataadmin/vendor/jqueryui/themes/base/jquery-ui.css
- bundles/sonatacore/vendor/select2/select2.css
- bundles/sonatacore/vendor/select2-bootstrap-css/select2-bootstrap.min.css
- bundles/sonataadmin/vendor/x-editable/dist/bootstrap3-editable/css/bootstrap-editable.css
- bundles/sonataadmin/css/styles.css
- bundles/sonataadmin/css/layout.css
- bundles/sonataadmin/css/tree.css
- bundles/sonataadmin/css/colors.css

# stylesheet paths to add to the page in addition to the list above
extra_stylesheets: []

# stylesheet paths to remove from the page
remove_stylesheets: []

javascripts:

# The default javascript list:
- 'bundles/sonatacore/vendor/jquery/dist/jquery.min.js'
- 'bundles/sonataadmin/vendor/jquery.scrollTo/jquery.scrollTo.min.js'
- 'bundles/sonataadmin/vendor/jqueryui/ui/minified/jquery-ui.min.js'
- 'bundles/sonataadmin/vendor/jqueryui/ui/minified/i18n/jquery-ui-i18n.min.js'
- 'bundles/sonatacore/vendor/moment/min/moment.min.js'
- 'bundles/sonatacore/vendor/bootstrap/dist/js/bootstrap.min.js'
- 'bundles/sonatacore/vendor/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js'
- 'bundles/sonataadmin/vendor/jquery-form/jquery.form.js'
- 'bundles/sonataadmin/jquery/jquery.confirmExit.js'
- 'bundles/sonataadmin/vendor/x-editable/dist/bootstrap3-editable/js/bootstrap-editable.min.js'
- 'bundles/sonatacore/vendor/select2/select2.min.js'
- 'bundles/sonataadmin/vendor/admin-lte/dist/js/app.min.js'
- 'bundles/sonataadmin/vendor/iCheck/icheck.min.js'
- 'bundles/sonataadmin/vendor/slimScroll/jquery.slimscroll.min.js'
- 'bundles/sonataadmin/vendor/waypoints/lib/jquery.waypoints.min.js'
- 'bundles/sonataadmin/vendor/waypoints/lib/shortcuts/sticky.min.js'
- 'bundles/sonataadmin/vendor/readmore-js/readmore.min.js'
- 'bundles/sonataadmin/vendor/masonry/dist/masonry.pkgd.min.js'
- 'bundles/sonataadmin/Admin.js'
- 'bundles/sonataadmin/treeview.js'
- 'bundles/sonataadmin/sidebar.js'

# javascript paths to add to the page in addition to the list above
extra_javascripts: []

# javascript paths to remove from the page
remove_javascripts: []

extensions:

Expand Down
38 changes: 38 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"dependencies": {
"admin-lte": "~2.3.10",
"bootstrap": "^3.3",
"eonasdan-bootstrap-datetimepicker": "~3.1.3",
"bootstrap3-dialog": "^1.34",
"font-awesome": "^4.7",
"icheck": "^1.0",
"ionicons": "^4.5.5",
"jquery": "^2.2.3",
"jquery-form": "^4.0",
"jquery-slimscroll": "^1.3",
"jquery-ui": "^1.12.1",
"jquery.scrollto": "^1.4",
"masonry": "^0.0.2",
silasjoisten marked this conversation as resolved.
Show resolved Hide resolved
"masonry-layout": "^4.2",
"moment": "^2.10",
"node-sass": "^4.11.0",
"readmore-js": "^2.2.1",
"sass-loader": "^7.0.1",
"select2": "^3.5",
"select2-bootstrap-css": "^1.4",
"waypoints": "^4.0",
"x-editable": "^1.5"
},
"devDependencies": {
"@symfony/webpack-encore": "^0.27.0",
"webpack-notifier": "^1.6.0"
},
"license": "UNLICENSED",
"private": true,
"scripts": {
"dev-server": "encore dev-server",
"dev": "encore dev",
"watch": "encore dev --watch",
"build": "encore production --progress"
}
}
44 changes: 44 additions & 0 deletions src/DependencyInjection/Compiler/WebpackEntriesCompilerPass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Sonata Project package.
*
* (c) Thomas Rabaix <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Sonata\AdminBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;

/**
* @author Silas Joisten <[email protected]>
*/
final class WebpackEntriesCompilerPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
{
$configs = $container->getExtensionConfig('webpack_encore');

$entries = [];
foreach ($configs as $config) {
if (!isset($config['builds'])) {
continue;
}

$entries = array_merge($entries, $config['builds']);
}

if (0 === \count($entries)) {
return;
}

$container->getDefinition('twig')
->addMethodCall('addGlobal', ['sonata_admin_webpack_entries', $entries]);
}
}
Loading