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

Add new Dandelion profiles #36

Closed
tduchateau opened this issue Sep 5, 2014 · 0 comments
Closed

Add new Dandelion profiles #36

tduchateau opened this issue Sep 5, 2014 · 0 comments

Comments

@tduchateau
Copy link
Member

... in order to address the problematics of different environments (dev, qa, prod).

Requirements

It should be possible to declare multiple locations for each asset of a bundle. For example:

{
   "bundle" : "jquery",
   "assets": [{
      "name": "jquery",
      "version": "1.11.0",
      "type": "js",
      "locations": {
         "cdn" : "//cdnjs.cloudflare.com/ajax/libs/jquery/1.11.0/jquery.js",
         "webapp" : "/assets/js/jquery.js"
      }
   }]
}

Profile definition

Then, for each different profile, a properties file will be needed.
For example :

src
|__ main
     |__ config
          |__ dandelion
               |__ dandelion.properties <== dev profile
               |__ dandelion_qa.properties <== QA profile
               |__ dandelion_prod.properties <== prod profile

Naming scheme: dandelion_[profileName].properties

In each profile, it will be possible :

  • to select the selection strategy of asset locations
asset.locations.selection.strategy = cdn,jar,webjar,webapp

In this example, the cdn location will be picked up as a priority if it exists in the asset definition, then jar, etc.
Dandelion must log if none of the locations declared in the above property is mentioned in the asset definition.

  • to define the same options as today
asset.minification = true
asset.processors = cssurlrewriting,jsmin,cssmin
  • and custom variables, in order to be able to perform variables substitution in the bundles
MEDIA.SERVER=https://my.media.server/

As a consequence, it will be possible to declare the following kind of asset location:

{
   "bundle" : "jquery",
   "assets": [{
      "name": "jquery",
      "version": "1.11.0",
      "type": "js",
      "locations": {
         "remote" : "%MEDIA.SERVER%/libs/jquery/jquery.js",
         "webapp" : "/assets/js/jquery.js"
      }
   }]
}

Syntax: %VARIABLE% will be used instead of ${VARIABLE} in order to avoid any conflict with Maven or any other build tool that use ${} to perform resource filtering.

Profile activation

The activation of a profile will be done using the following system property :
-Ddandelion.profile.active=prod

Once the profile is retrieved at initialization, the right properties file will be loaded, i.e. dandelion_prod.properties in the example.

The profile name must be case-insensitive.
Only one profile can be activated at a time.

@tduchateau tduchateau self-assigned this Sep 5, 2014
@tduchateau tduchateau added this to the 0.11.0 milestone Sep 5, 2014
tduchateau added a commit that referenced this issue Sep 10, 2014
 * The StandardConfigurationLoader has been updated in order to be able to load different properties files depending on the active profile.
 * A profile is activated using the -Ddandelion.profile.active system property
 * Some reserved words are used to load preconfigured sets of configurations
    * "", "dev", "development" => each DandelionConfig entry is configured using the default dev value
    * "prod", "production" => each DandelionConfig entry is configured using the default prod value
 * Any custom profile name can be used. All configurations that are not specified in the corresponding properties file will be initialized with default dev values.
 * Plenty of configuration points have been renamed or added (toolAssetPrettyPrintingEnabled, toolBundleGraphEnabled, assetCachingEnabled, ...) for more consistency

Regarding #36, it only lacks variables substitution and corresponding tests obviously.
tduchateau added a commit that referenced this issue Sep 10, 2014
 * Added new utilities method allowing to perform variable substitution
 * At startup, a new finalization step is executed during the filling of the BundleStorage to perform variable substitution in asset locations
 * Asset names are now stored lowercase when deducted from the asset location (fixing a regression in bundles/assets exclusions)
 * Code cleaning (new comments, useless checks, ...)

Closes #36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant