Skip to content

Commit

Permalink
New webpack tag syntax. New commons chunk groups
Browse files Browse the repository at this point in the history
  • Loading branch information
steven-prybylynskyi committed Jun 24, 2017
1 parent 3c12fdd commit 54e6b31
Show file tree
Hide file tree
Showing 174 changed files with 4,526 additions and 2,781 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ indent_style = tab
indent_size = 4
insert_final_newline = true

[*.yml]
[*.{json,yml}]
indent_style = space
10 changes: 7 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
.idea/

node_modules/
vendor/

.php_cs.cache
composer.phar
composer.lock
yarn.lock

tests/_output/
tests/_support/_generated/

tests/functional/Fixtures/app/cache/
tests/functional/Fixtures/app/config/symfony.webpack.config.js
tests/functional/Fixtures/app/config/webpack-rules.js
tests/functional/Fixtures/node_modules/
tests/functional/Fixtures/app/config/webpack.default.config.js
tests/functional/Fixtures/app/config/webpack.symfony.config.js
tests/functional/Fixtures/app/logs/
tests/functional/Fixtures/web/
tests/functional/Fixtures/package.json
38 changes: 38 additions & 0 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests/functional')
->in(__DIR__ . '/tests/unit')
;

/**
* Rules for PHP Coding Standards Fixer
* http://cs.sensiolabs.org/#using-php-cs-fixer-on-ci
*/
return PhpCsFixer\Config::create()
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,

// override Symfony rules
'concat_space' => [
'spacing' => 'one',
],
'is_null' => [
'use_yoda_style' => false,
],

// additional rules
'heredoc_to_nowdoc' => true,
'linebreak_after_opening_tag' => true,
'no_unreachable_default_argument_value' => true,
'no_useless_return' => true,
'phpdoc_add_missing_param_annotation' => true,
'strict_comparison' => true,
])
->setIndent("\t")
->setLineEnding("\n")
->setRiskyAllowed(true)
->setFinder($finder)
;
41 changes: 29 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,55 @@
# https://docs.travis-ci.com/user/customizing-the-build

language: php

sudo: false

php:
- 5.6

env:
global:
- TRAVIS_NODE_VERSION="6"
- COMPOSER_NO_INTERACTION="1"
matrix:
# install vendor packages with lowest version
- COMPOSER_ARGS="--prefer-lowest"
# install vendor packages with newest version and run Codeception with coverage
- WITH_COVERAGE=true

matrix:
include:

# install vendor packages with lowest version
# - php: 5.4
# env: COMPOSER_ARGS="--prefer-lowest"

# install vendor packages with newest version and run Codeception with coverage
- php: 7.1
env: WITH_COVERAGE=true

# with PHP Coding Standards Fixer
- php: 7.1
env: WITH_CS_FIXER=true

cache:
directories:
- $HOME/.composer/cache
- $HOME/.npm
yarn: true

before_install:
- if [ -z "${WITH_COVERAGE}" ]; then phpenv config-rm xdebug.ini; fi
- if [ -z "$WITH_COVERAGE" ]; then phpenv config-rm xdebug.ini; fi

install:
- rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install $TRAVIS_NODE_VERSION
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH=$HOME/.yarn/bin:$PATH

# Using PHP CS Fixer on CI http://cs.sensiolabs.org/#using-php-cs-fixer-on-ci
- IFS=$'\n'; COMMIT_SCA_FILES=($(git diff --name-only --diff-filter=ACMRTUXB "${TRAVIS_COMMIT_RANGE}")); unset IFS

before_script:
- bash -c "composer update $COMPOSER_ARGS"

script:
- if [ "${WITH_COVERAGE}" == "true" ]; then COVERAGE_OPTION="--coverage-xml"; fi
- if [ "$WITH_COVERAGE" == "true" ]; then COVERAGE_OPTION="--coverage-xml"; fi
- vendor/bin/codecept run $COVERAGE_OPTION

after_success:
# send coverage report to coveralls.io
- if [ "${WITH_COVERAGE}" == "true" ]; then travis_retry php vendor/bin/coveralls; fi
# Run PHP Coding Standards Fixer
- if [[ "$WITH_CS_FIXER" == "true" ]]; then vendor/bin/php-cs-fixer fix --config=.php_cs -v --dry-run --stop-on-violation --using-cache=no --path-mode=intersection "${COMMIT_SCA_FILES[@]}"; fi
# Send coverage report to coveralls.io
- if [ "$WITH_COVERAGE" == "true" ]; then travis_retry php vendor/bin/coveralls; fi
23 changes: 23 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
The MIT License (MIT)

Copyright (c) 2016 Marius Balčytis
Copyright (c) 2017 Steven Pribilinskiy

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,21 @@ Single entry point (`.js`, `.ts`, `.coffee` etc.) in `twig` templates:
Multiple entry points:

```twig
{% webpack_javascripts
{% webpack js
'@acmeHello/main.js'
'@acmeHello/another-entry-point.js'
%}
<script defer src="{{ asset_url }}"><script>
{% end_webpack_javascripts %}
{% end_webpack %}
```

```twig
{% webpack_stylesheets
{% webpack css
'@acmeHello/main.js'
'@acmeHello/another-entry-point.js'
%}
<link rel="stylesheet" href="{{ asset_url }}"><script>
{% end_webpack_stylesheets %}
{% end_webpack %}
```

To avoid having a `link` element with an empty `href` in the DOM when the script may possibly not emit a stylesheet, test the value returned from `webpack_asset` before inserting the `link` element:
Expand Down Expand Up @@ -103,16 +103,17 @@ module.exports = function makeWebpackConfig(symfonyOptions) {
}
```

Then add the script that will load the common libs before any other script that may depend on it. Use the `webpack_entry` function to inject the actual compiled asset path:
Then add the script that will load the common libs before any other script that may depend on it.
Use the `webpack_named_asset` function to inject the actual compiled asset path:

```twig
<script defer src="{{ webpack_entry('jquery-and-lodash') }}"><script>
<script defer src="{{ webpack_named_asset('jquery-and-lodash') }}"><script>
```

Commons chunk may contain other type of assets:

```twig
<link rel="stylesheet" href="{{ webpack_entry('shared', 'css') }}">
<link rel="stylesheet" href="{{ webpack_named_asset('shared', 'css') }}">
```

The rendered output of above in production mode will be something like:
Expand All @@ -133,19 +134,19 @@ You can pass any kind of resources to webpack with `webpack_asset` function for
<img src="{{ webpack_asset('@AcmeHelloBundle/Resources/public/images/background.jpg') }}">
```

Or with `webpack_assets` tag for multiple entry points:
Or with `webpack` tag for multiple entry points:

```
<ul class="nav nav-pills social-icons">
{% webpack_assets
{% webpack
'@AcmeHelloBundle/Resources/public/images/facebook.jpg'
'@AcmeHelloBundle/Resources/public/images/twitter.jpg'
'@AcmeHelloBundle/Resources/public/images/youtube.jpg'
%}
<li>
<img src="{{ asset_url }}">
</li>
{% end_webpack_assets %}
{% end_webpack %}
</ul>
```

Expand Down
6 changes: 6 additions & 0 deletions codeception.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
actor: Tester

paths:
tests: tests
log: tests/_output
data: tests/_data
support: tests/_support
envs: tests/_envs

settings:
bootstrap: _bootstrap.php
colors: true
memory_limit: 1024M

extensions:
enabled:
- Codeception\Extension\Logger
- Codeception\Extension\Recorder
- Codeception\Extension\RunFailed

coverage:
enabled: true
include:
Expand Down
27 changes: 15 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,23 @@
}
],
"require": {
"php": ">=5.3.2",
"symfony/framework-bundle": "^2.7|^3.0",
"symfony/templating": "^2.1|^3.0",
"symfony/console": "^2.5|^3.0",
"symfony/routing": "^2.7|^3.0",
"twig/twig": "^1.27|^2.0",
"maba/dependency-injection-extra": "^0.1.1",
"symfony/process": "^2.5|^3.0",
"php": ">=7.0",
"satooshi/php-coveralls": "^1.0",
"symfony/console": "^2.5|^3.0",
"symfony/dependency-injection": "^2.6|^3.0",
"symfony/twig-bundle": "^2.3|^3.0",
"symfony/framework-bundle": "^2.7|^3.0",
"symfony/monolog-bundle": "^2.3|^3.0",
"satooshi/php-coveralls": "^1.0"
"symfony/process": "^2.5|^3.0",
"symfony/routing": "^2.7|^3.0",
"symfony/templating": "^2.1|^3.0",
"symfony/twig-bundle": "^2.3|^3.0",
"twig/twig": "^1.27|^2.0"
},
"require-dev": {
"codeception/codeception": "~2.1.4",
"friendsofphp/php-cs-fixer": "^2.2",
"symfony/framework-bundle": "^2.7.1|^3.0",
"codeception/codeception": "~2.3.3",
"symfony/translation": "^2.7|^3.0",
"symfony/asset": "^2.7|^3.0",
"doctrine/annotations": "^1.0"
Expand All @@ -36,7 +38,8 @@
},
"autoload-dev": {
"psr-4": {
"Fixtures\\GoldenPlanet\\": "tests/functional/Fixtures/src"
"Fixtures\\": "tests/functional/Fixtures/src"
}
}
},
"minimum-stability": "RC"
}
23 changes: 0 additions & 23 deletions src/AssetProvider/AssetProviderInterface.php

This file was deleted.

72 changes: 0 additions & 72 deletions src/AssetProvider/AssetResult.php

This file was deleted.

0 comments on commit 54e6b31

Please sign in to comment.