This repository has been archived by the owner on Dec 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
139 lines (131 loc) · 4.27 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
var path = require('path'),
typings = require('typings');
module.exports = function(grunt) {
var webpack = require('webpack');
var webpackConfig = require('./webpack.config.js');
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('./package.json'),
clean: {
prebuild: {
src: ['./www/**/*', '!./www/.gitignore']
}
},
copy: {
build: {
files: [
{
expand: true,
cwd: './src/themes',
src: ['./**/assets/**'],
dest: './www/themes'
},
{
src: './src/index.html',
dest: './www/index.html'
}
]
},
config: {
src: './src/modules/config/registration-info.json.template',
dest: './src/modules/config/registration-info.json',
// Copy if file does not exist.
filter: function (aFilePath) {
var dest = grunt.config('copy.config.dest');
var exists = grunt.file.exists(path.resolve(dest));
if (exists) {
grunt.log.writeln('Config file "'['green'] + dest + '" already exists.'['green']);
} else {
grunt.log.writeln('Config file "'['green'] + dest + '" has been created.'['green']);
}
grunt.log.writeln('Enter your app credentials into the file before build.'['green']);
return !exists;
}
}
},
run: {
init: {
cmd: 'cordova',
args: [
'prepare'
]
}
},
webpack: {
options: webpackConfig,
build: {
plugins: webpackConfig.plugins.concat(
new webpack.DefinePlugin({
'process.env': {
// This has effect on the react lib size
'NODE_ENV': JSON.stringify('production')
}
}),
new webpack.optimize.UglifyJsPlugin()
)
},
'build-dev': {
devtool: 'sourcemap',
debug: true
}
},
less: {
build: {
options: {
paths: ['./src'],
plugins: [
new (require('less-plugin-autoprefix'))({browsers: ['last 2 versions']}),
new (require('less-plugin-clean-css'))()
],
modifyVars: {
// themesPath: '"themes"'
}
},
files: [
{
expand: true,
cwd: './src/themes',
src: ['./*.less'],
dest: './www/themes',
ext: '.css'
}
]
},
'build-dev': {
options: {
paths: ['./src'],
sourceMap: true
},
files: [
{
expand: true,
cwd: './src/themes',
src: ['./*.less'],
dest: './www/themes',
ext: '.css'
}
]
}
}
});
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-run');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-webpack');
grunt.registerTask('install-typings', function () {
var done = this.async();
typings.install({
cwd: './src'
})
.then(function () {
done(true);
})
.catch(function () {
done(false);
});
});
grunt.registerTask('init', ['install-typings', 'run:init', 'copy:config']);
grunt.registerTask('build', ['clean:prebuild', 'webpack:build', 'less:build', 'copy:build']);
grunt.registerTask('build-dev', ['clean:prebuild', 'webpack:build-dev', 'less:build-dev', 'copy:build']);
};