@@ -40,6 +40,7 @@ Configuration
40
40
* `base_path `_
41
41
* `base_urls `_
42
42
* `json_manifest_path `_
43
+ * `package_json_path `_
43
44
* `packages `_
44
45
* `version_format `_
45
46
* `version_strategy `_
@@ -1116,6 +1117,7 @@ Each package can configure the following options:
1116
1117
* :ref: `version <reference-framework-assets-version >`
1117
1118
* :ref: `version_format <reference-assets-version-format >`
1118
1119
* :ref: `json_manifest_path <reference-assets-json-manifest-path >`
1120
+ * :ref: `package_json_path <reference-assets-package-json-path >`
1119
1121
1120
1122
.. _reference-framework-assets-version :
1121
1123
.. _ref-framework-assets-version :
@@ -1184,7 +1186,8 @@ option.
1184
1186
1185
1187
.. note ::
1186
1188
1187
- This parameter cannot be set at the same time as ``version_strategy `` or ``json_manifest_path ``.
1189
+ This parameter cannot be set at the same time as
1190
+ ``version_strategy ``, ``json_manifest_path `` or ``package_json_path ``.
1188
1191
1189
1192
.. tip ::
1190
1193
@@ -1317,7 +1320,7 @@ individually for each asset package:
1317
1320
1318
1321
.. note ::
1319
1322
1320
- This parameter cannot be set at the same time as ``version `` or ``json_manifest_path ``.
1323
+ This parameter cannot be set at the same time as ``version ``, `` json_manifest_path `` or ``package_json_path ``.
1321
1324
1322
1325
.. _reference-assets-json-manifest-path :
1323
1326
.. _reference-templating-json-manifest-path :
@@ -1415,6 +1418,100 @@ package:
1415
1418
If you request an asset that is *not found * in the ``manifest.json `` file, the original -
1416
1419
*unmodified * - asset path will be returned.
1417
1420
1421
+
1422
+ package_json_path
1423
+ ..................
1424
+
1425
+ **type **: ``string `` **default **: ``null ``
1426
+
1427
+ The file path to a ``package.json `` file containing a json with a version number
1428
+ which is increased by using ``npm version patch --git-tag-version false `` at the
1429
+ build time of the assets.
1430
+
1431
+ This option can be set globally for all assets and individually for each asset
1432
+ package:
1433
+
1434
+ .. configuration-block ::
1435
+
1436
+ .. code-block :: yaml
1437
+
1438
+ # config/packages/framework.yaml
1439
+ framework :
1440
+ assets :
1441
+ # this version is applied to every asset (including packages)
1442
+ package_json_path : " %kernel.project_dir%/package.json"
1443
+ packages :
1444
+ foo_package :
1445
+ # this package uses its own version (the default file is ignored)
1446
+ package_json_path : " %kernel.project_dir%/assets/different/package.json"
1447
+ bar_package :
1448
+ # this package uses the global version (the default file is used)
1449
+ base_path : ' /images'
1450
+
1451
+ .. code-block :: xml
1452
+
1453
+ <!-- config/packages/framework.xml -->
1454
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
1455
+ <container xmlns =" http://symfony.com/schema/dic/services"
1456
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
1457
+ xmlns : framework =" http://symfony.com/schema/dic/symfony"
1458
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
1459
+ http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
1460
+
1461
+ <framework : config >
1462
+ <!-- this version is applied to every asset (including packages) -->
1463
+ <framework : assets package-json-path =" %kernel.project_dir%/package.json" >
1464
+ <!-- this package uses its own version (the default file is ignored) -->
1465
+ <framework : package
1466
+ name =" foo_package"
1467
+ package-json-path =" %kernel.project_dir%/assets/different/package.json" />
1468
+ <!-- this package uses the global version (the default file is used) -->
1469
+ <framework : package
1470
+ name =" bar_package"
1471
+ base-path =" /images" />
1472
+ </framework : assets >
1473
+ </framework : config >
1474
+ </container >
1475
+
1476
+ .. code-block :: php
1477
+
1478
+ // config/packages/framework.php
1479
+ $container->loadFromExtension('framework', array(
1480
+ 'assets' => array(
1481
+ // this version is applied to every asset (including packages)
1482
+ 'package_json_path' => '%kernel.project_dir%/package.json',
1483
+ 'packages' => array(
1484
+ 'foo_package' => array(
1485
+ // this package uses its own version (the default file is ignored)
1486
+ 'package_json_path' => '%kernel.project_dir%/assets/different/package.json',
1487
+ ),
1488
+ 'bar_package' => array(
1489
+ // this package uses the global version (the default file is used)
1490
+ 'base_path' => '/images',
1491
+ ),
1492
+ ),
1493
+ ),
1494
+ ));
1495
+
1496
+ Example ``package.json `` file:
1497
+
1498
+ .. code-block :: js
1499
+
1500
+ {
1501
+ " version" : " 1.2.3" ,
1502
+ " scripts" : {
1503
+ " build" : " npm run build:assets && npm run version:patch" ,
1504
+ " build:assets" : " ..." ,
1505
+ " version:patch" : " npm version patch --git-tag-version false"
1506
+ }
1507
+ }
1508
+
1509
+ .. note ::
1510
+
1511
+ This parameter cannot be set at the same time as ``version `` or ``version_strategy ``.
1512
+ Additionally, this option cannot be nullified at the package scope if a global package.json
1513
+ file is specified.
1514
+
1418
1515
templating
1419
1516
~~~~~~~~~~
1420
1517
0 commit comments