Skip to content

feat: allow options to customize pattern and hash length#47

Merged
metonym merged 3 commits intomasterfrom
enhance-plugin-options
Jul 16, 2020
Merged

feat: allow options to customize pattern and hash length#47
metonym merged 3 commits intomasterfrom
enhance-plugin-options

Conversation

@metonym
Copy link
Copy Markdown
Collaborator

@metonym metonym commented Jul 15, 2020

Closes #46 , closes #45


Backwards compatible API change that allows the pattern RegExp and hash length to be customized.

Example:

hash({
  path: 'public', // default is `""`
  pattern: new RegExp(/\[oh-my-hash.*]/g), // default is `new RegExp(/\[hash.*]/g)`
  hashLength: 8 // default is `20`
})
- script.[oh-my-hash].js
+ script.b0dcc67f.js

TODO

  • update/add unit tests
  • update/add integration tests
  • ideally add an end-to-end standalone example
  • update documentation

@metonym
Copy link
Copy Markdown
Collaborator Author

metonym commented Jul 16, 2020

@frederikhors

Added an integration test for a custom pattern and hash length:

hash({
  pattern: new RegExp(/\oh-my-hash/),
  hashLength: 8,
})

With a custom RegExp pattern, you are not required to use square brackets.

- <script src="script.oh-my-hash.js"></script>
+ <script src="script.b0dcc67f.js"></script>

@frederikhors
Copy link
Copy Markdown

Do you really like "oh-my-hash", don't you?! 😄 LOL

@metonym metonym marked this pull request as ready for review July 16, 2020 13:31
@metonym metonym merged commit a0c3404 into master Jul 16, 2020
@metonym metonym deleted the enhance-plugin-options branch July 16, 2020 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hash length placeholder is a problem with postcss Doesn't work with Rollup output.entryFileNames

2 participants