This repository has been archived by the owner on Aug 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 58
Add RegExp support and strict order of entries (+unit-tests) #53
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
1c2746a
Add RegExp support and strict order of entries (+unit-tests)
thiscantbeserious 8c8a9f9
Updated README.md to reflect change in options
thiscantbeserious 44a6bb8
Updated README.me to reflect changes to options
thiscantbeserious 5840769
Updated README.me to reflect changes to options
thiscantbeserious b36a448
Switched to instanceof instead of isRegEx option in entries to keep c…
thiscantbeserious cc65629
Merge branch 'master' of https://github.com/thiscantbeserious/rollup-…
thiscantbeserious f8aa997
Fixes after Code-Review
thiscantbeserious 8b3897c
Update README.md
thiscantbeserious f88970a
Update README.md
thiscantbeserious fd11e6d
Update README.md
thiscantbeserious 4445ccf
Update README.md
thiscantbeserious a5acc4b
Update README.md
thiscantbeserious 1dbb8c0
Update README.md
thiscantbeserious 8e0cf29
Update README.md
thiscantbeserious a1d975e
Update README.md
thiscantbeserious 9c9d6c7
Update README.md
thiscantbeserious 7287338
Update README.md
thiscantbeserious c13f8d1
Update README.md
thiscantbeserious 036186c
Update README.md
thiscantbeserious File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,36 +27,31 @@ For Webpack users: This is a plugin to mimic the `resolve.alias` functionality i | |
``` | ||
$ npm install rollup-plugin-alias | ||
``` | ||
|
||
# | ||
## Usage | ||
```javascript | ||
// rollup.config.js | ||
import alias from 'rollup-plugin-alias'; | ||
|
||
export default { | ||
input: './src/index.js', | ||
plugins: [alias({ | ||
somelibrary: './mylocallibrary' | ||
})], | ||
plugins: [ | ||
alias({ | ||
resolve: ['.jsx', '.js'], //optional, by default this will just look for .js files or folders | ||
entries:[ | ||
{find:'something', replacement: '../../../something'}, //the initial example | ||
{find:'somelibrary-1.0.0', replacement: './mylocallibrary-1.5.0'}, //remap a library with a specific version | ||
{find:/^i18n\!(.*)/, replacement: '$1.js'}, //remove something in front of the import and append an extension (e.g. loaders, for files that were previously transpiled via the AMD module, to properly handle them in rollup as internals now) | ||
//for whatever reason, replace all .js extensions with .wasm | ||
{find:/^(.*)\.js$/, replacement: '$1.wasm'} | ||
] | ||
}) | ||
], | ||
}; | ||
``` | ||
The order of the entries is important, in that the first rules are applied first. | ||
|
||
An optional `resolve` array with file extensions can be provided. | ||
If present local aliases beginning with `./` will be resolved to existing files: | ||
|
||
```javascript | ||
// rollup.config.js | ||
import alias from 'rollup-plugin-alias'; | ||
|
||
export default { | ||
input: './src/index.js', | ||
plugins: [alias({ | ||
resolve: ['.jsx', '.js'], | ||
foo: './bar' // Will check for ./bar.jsx and ./bar.js | ||
})], | ||
}; | ||
``` | ||
If not given local aliases will be resolved with a `.js` extension. | ||
You can use either simple Strings or Regular Expressions to search in a more distinct and complex manner (e.g. to do partial replacements via subpattern-matching, see aboves example). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks good 👍 |
||
|
||
## License | ||
MIT, see `LICENSE` for more information |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this intended?