forked from benjaminhoffman/gatsby-plugin-mailchimp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-node.js
29 lines (26 loc) · 965 Bytes
/
gatsby-node.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
'use strict';
exports.onCreateWebpackConfig = function(_ref, _ref2) {
var plugins = _ref.plugins,
actions = _ref.actions;
var endpoint = _ref2.endpoint,
_ref2$timeout = _ref2.timeout,
timeout = _ref2$timeout === void 0 ? 3500 : _ref2$timeout;
var isString = typeof endpoint === 'string';
if (!isString) {
throw new Error(
'Mailchimp endpoint required and must be of type string. See repo README for more info.',
);
} else if (endpoint.length < 40) {
throw new Error(
'gatsby-plugin-mailchimp: donʼt forget to add your MC endpoint to your gatsby-config file. See README for more info.',
);
}
actions.setWebpackConfig({
plugins: [
plugins.define({
__GATSBY_PLUGIN_MAILCHIMP_ADDRESS__: JSON.stringify(endpoint),
__GATSBY_PLUGIN_MAILCHIMP_TIMEOUT__: Number(timeout),
}),
],
});
};