forked from Airtable/airtable.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gruntfile.js
66 lines (63 loc) · 2.9 KB
/
gruntfile.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
'use strict';
module.exports = function(grunt) {
var pkg = grunt.file.readJSON('package.json');
grunt.initConfig({
pkg: pkg,
browserify: {
umd: {
// During our build script, we copy lib/airtable.js to lib/tmp_airtable.js and use the tmp file here.
// This is necessary because in our package.json we replace lib/airtable.js with lib/airtable.umd.js
// for browser builds. We have this setting because we want to make sure that when _other_ apps
// include airtable.js as a dependency and are bundled for a browser target, they bundle the UMD build
// rather than the node build. However, since we replace lib/airtable.js with lib/airtable.umd.js in
// browser builds, browserify is unable to use lib/airtable.js as the src in our own browser builds.
// Therefore, we copy it to a tmp file and use that as the src.
// GitHub issue https://github.com/browserify/browserify/issues/1746
src: './lib/tmp_airtable.js',
dest: './lib/airtable.umd.js',
options: {
transform: [
[
'envify',
// IMPORTANT: mask out environment variables that should never be shipped to the browser
{
_: 'purge',
AIRTABLE_ENDPOINT_URL: '',
AIRTABLE_API_KEY: '',
npm_package_version: pkg.version,
},
],
],
preBundleCB: function(b) {
b.require('./lib/tmp_airtable.js', {expose: 'airtable'});
},
browserifyOptions: {
standalone: 'Airtable',
},
},
},
browser: {
src: './lib/tmp_airtable.js',
dest: './build/airtable.browser.js',
options: {
transform: [
[
'envify',
// IMPORTANT: mask out environment variables that should never be shipped to the browser
{
_: 'purge',
AIRTABLE_ENDPOINT_URL: '',
AIRTABLE_API_KEY: '',
npm_package_version: pkg.version,
},
],
],
preBundleCB: function(b) {
b.require('./lib/tmp_airtable.js', {expose: 'airtable'});
},
},
},
},
});
grunt.loadNpmTasks('grunt-browserify');
};