Skip to content
New issue

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

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

Already on GitHub? # to your account

RFC: Feature/asset versioning #241

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

JanDC
Copy link
Member

@JanDC JanDC commented Jan 26, 2021

Q A
Branch? feature/asset-versioning -> master
Bug fix? no
New feature? yes
Deprecations? no, optional superset of current features
Passes tests? Yes, current and new tests (versioned subtasks are not yet covered)
Additional dependencies? Yes, 'hasha' to simplify file hashing

This PR consists of a first draft of generating versioned assets in buildozer. This feature works as such:

  • Addition of optional 'manifest_source' entry in root config:
    • Relative path to the dest_base_path, pointing to the assets being versioned
    • Defaults to the dest_base_path entry
  • Addition of optional 'manifest' entry in root config, which can be a:
    • string value: location of the manifest file, relative to the provided manifest_source (or dest_base_path when the former is ommitted). I.e. './dist/manifest.json'
    • A list of subtasks: a list of manifest locations, indexed by subtask. The manifest will be placed relative to the subtask's 'dest' location. I.e. css: './manifest.json'
  • Versions are based on file hashes and should remain unchanged if no content has changed.
  • if the 'manifest' entry is missing, no versioning will occur. A config with solely a manifest_source will not result in any changes in output.
  • This feature is completely optional, current projects shouldn't be affected by the changes in this PR.

Notes:

  • The versioned assets are copies of the original, keeping the source files in place.
  • Only .js and .css will be versioned, other file types could be added should the need arise.
  • Versioning will only occur on builds, not when runnning the watch task.

Checklist

  • First draft
  • Tests
  • Documentation
  • Integration in watch tasks
  • Peer review 😃

@@ -107,7 +108,7 @@ function setEnvironment(cb) {
}

// Define complex tasks
const build = gulp.series(setEnvironment, clean, copy, gulp.parallel(css, js, img));
const build = gulp.series(setEnvironment, clean, copy, gulp.parallel(css, js, img), versionAssets);
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be more performant to version assets in the gulp stream. This way we won't need to do these tasks twice:

  • Glob file search
  • File content read

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants