You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 4, 2021. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+15-20Lines changed: 15 additions & 20 deletions
Display the source diff
Display the rich diff
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
27
27
```
28
28
$ npm install rollup-plugin-alias
29
29
```
30
-
30
+
#
31
31
## Usage
32
32
```javascript
33
33
// rollup.config.js
34
34
importaliasfrom'rollup-plugin-alias';
35
35
36
36
exportdefault {
37
37
input:'./src/index.js',
38
-
plugins: [alias({
39
-
somelibrary:'./mylocallibrary'
40
-
})],
38
+
plugins: [
39
+
alias({
40
+
resolve: ['.jsx', '.js'], //optional, by default this will just look for .js files or folders
41
+
entries:[
42
+
{find:'something', replacement:'../../../something'}, //the initial example
43
+
{find:'somelibrary-1.0.0', replacement:'./mylocallibrary-1.5.0'}, //remap a library with a specific version
44
+
{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)
45
+
//for whatever reason, replace all .js extensions with .wasm
46
+
{find:/^(.*)\.js$/, replacement:'$1.wasm'}
47
+
]
48
+
})
49
+
],
41
50
};
42
51
```
52
+
The order of the entries is important, in that the first rules are applied first.
43
53
44
-
An optional `resolve` array with file extensions can be provided.
45
-
If present local aliases beginning with `./` will be resolved to existing files:
46
-
47
-
```javascript
48
-
// rollup.config.js
49
-
importaliasfrom'rollup-plugin-alias';
50
-
51
-
exportdefault {
52
-
input:'./src/index.js',
53
-
plugins: [alias({
54
-
resolve: ['.jsx', '.js'],
55
-
foo:'./bar'// Will check for ./bar.jsx and ./bar.js
56
-
})],
57
-
};
58
-
```
59
-
If not given local aliases will be resolved with a `.js` extension.
54
+
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).
0 commit comments