forked from inpercima/run-and-fun
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
120 lines (105 loc) · 3.48 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
/* globals module, require */
const loadGruntTasks = require('load-grunt-tasks');
module.exports = function(grunt) {
'use strict';
loadGruntTasks(grunt);
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
buildAppJs: 'build/resources/main/public/js/app.js',
buildAppMinJs: 'build/resources/main/public/js/app.min.js',
buildDirCss: 'build/resources/main/public/css',
buildDirFonts: 'build/resources/main/public/fonts',
buildDirJs: 'build/resources/main/public/js',
buildFilesJs: 'build/resources/main/public/js/*.js*',
gruntfileJs: 'Gruntfile.js',
srcAppJs: 'src/main/resources/public/js/app.js',
srcConfigJson: 'src/main/resources/public/js/config.json',
srcFilesJs: 'src/main/resources/public/js/**/*.js',
babel: {
options: {
presets: ['es2015'],
},
dist: {
files: {
'<%= concat.core.dest %>': '<%= concat.core.dest %>',
},
},
},
eslint: {
options: {
configFile: '.eslintrc.json',
},
target: ['<%= gruntfileJs %>', '<%= srcFilesJs %>'],
},
concat: {
options: {
separator: grunt.util.linefeed,
},
// first build without app.js
core: {
src: ['<%= srcFilesJs %>', '!<%= srcAppJs %>', '!<%= srcConfigJson %>'],
dest: '<%= buildAppJs %>',
},
// second build with prepended app.js
dist: {
src: ['<%= srcAppJs %>', '<%= buildAppJs %>', '!<%= srcConfigJson %>'],
dest: '<%= buildAppJs %>',
},
},
uglify: {
options: {
// the banner is inserted at the top of the output
banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n',
},
dist: {
src: '<%= buildAppJs %>',
dest: '<%= buildAppMinJs %>',
},
},
watch: {
files: ['<%= gruntfileJs %>', '<%= srcFilesJs %>'],
tasks: ['build'],
},
clean: {
build: {
src: '<%= buildFilesJs %>',
},
dist: {
src: '<%= buildAppJs %>',
},
},
copy: {
dist: {
files: [
// js
{ src: ['node_modules/angular/angular.min.js'], dest: '<%= buildDirJs %>/angular.min.js' },
{
src: ['node_modules/angular-chart.js/dist/angular-chart.min.js'],
dest: '<%= buildDirJs %>/angular-chart.min.js',
},
{
src: ['node_modules/angular-route/angular-route.min.js'],
dest: '<%= buildDirJs %>/angular-route.min.js',
},
{
src: ['node_modules/angular-ui-bootstrap/dist/ui-bootstrap-tpls.js'],
dest: '<%= buildDirJs %>/angular-ui-bootstrap-tpls.js',
},
{ src: ['node_modules/chart.js/dist/Chart.min.js'], dest: '<%= buildDirJs %>/Chart.min.js' },
{ src: ['node_modules/lodash/lodash.min.js'], dest: '<%= buildDirJs %>/lodash.min.js' },
// json
{ src: ['src/main/resources/public/js/config.json'], dest: '<%= buildDirJs %>/config.json' },
// css
{
src: ['node_modules/bootstrap/dist/css/bootstrap.min.css'],
dest: '<%= buildDirCss %>/bootstrap.min.css',
},
// fonts
{ expand: true, cwd: 'node_modules/bootstrap/dist/fonts/', src: ['**'], dest: '<%= buildDirFonts %>' },
],
},
},
});
grunt.registerTask('build', ['clean:build', 'eslint', 'concat', 'babel', 'uglify', 'copy', 'clean:dist']);
grunt.registerTask('default', ['eslint']);
};