-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.js
48 lines (47 loc) · 1.74 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
const fs = require('fs');
"use strict";
module.exports = function (grunt) {
grunt.initConfig({
copy: {
"http-clean": {
src: 'src/utils/request/http-template.js',
dest: 'src/utils/request/http.js'
},
"http-node": {
src: 'src/utils/request/http-node.js',
dest: 'src/utils/request/http.js'
},
"http-browser": {
src: 'src/utils/request/http-browser.js',
dest: 'src/utils/request/http.js'
},
"http-browser-es5": {
src: 'src/utils/request/http-browser.es5.js',
dest: 'src/utils/request/http.js'
},
"http-react-native": {
src: 'src/utils/request/http-react-native.js',
dest: 'src/utils/request/http.js'
},
},
concat: {
es5polyfills: {
src: ['polyfills/core-js-bundle-3.6.4.min.js', 'dist/browser/piano-analytics.es5.js'],
dest: 'dist/browser/piano-analytics.es5.js',
},
},
});
grunt.registerTask('get-version', 'Copy version to the configuration', function() {
try {
const packageJsonVersion = JSON.parse(fs.readFileSync('./package.json', 'utf8')).version;
let configFile = fs.readFileSync('./src/config.js', 'utf8');
configFile = configFile.replace(/'version': '.*'/,`'version': '${packageJsonVersion}'`);
fs.writeFileSync('./src/config.js', configFile);
} catch (err) {
console.error(err);
process.exit(1);
}
});
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-concat');
};