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
Copy file name to clipboardExpand all lines: src/content/configuration/externals.md
+33Lines changed: 33 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,7 @@ contributors:
7
7
- pksjce
8
8
- fadysamirsadek
9
9
- byzyk
10
+
- zefman
10
11
---
11
12
12
13
The `externals` configuration option provides a way of excluding dependencies from the output bundles. Instead, the created bundle relies on that dependency to be present in the consumer's environment. This feature is typically most useful to __library developers__, however there are a variety of applications for it.
@@ -148,5 +149,37 @@ module.exports = {
148
149
149
150
In this case any dependency named `jQuery`, capitalized or not, or `$` would be externalized.
150
151
152
+
### Combining syntaxes
153
+
154
+
Sometimes you may want to use a combination of the above syntaxes. This can be done in the following manner:
155
+
156
+
```js
157
+
module.exports= {
158
+
//...
159
+
externals: [
160
+
{
161
+
// String
162
+
react:'react',
163
+
// Object
164
+
lodash : {
165
+
commonjs:'lodash',
166
+
amd:'lodash',
167
+
root:'_'// indicates global variable
168
+
},
169
+
// Array
170
+
subtract: ['./math', 'subtract']
171
+
},
172
+
// Function
173
+
function(context, request, callback) {
174
+
if (/^yourregex$/.test(request)){
175
+
returncallback(null, 'commonjs '+ request);
176
+
}
177
+
callback();
178
+
},
179
+
// Regex
180
+
/^(jquery|\$)$/i
181
+
]
182
+
};
183
+
```
151
184
152
185
For more information on how to use this configuration, please refer to the article on [how to author a library](/guides/author-libraries).
0 commit comments