-
Notifications
You must be signed in to change notification settings - Fork 2
/
GruntFile.js
137 lines (132 loc) · 5 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
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
banner: grunt.file.read('banner.js'),
dirs: {
scss: "src/scss",
css: "src/css",
js: "src/js",
demo: "demo",
build: "build"
},
watch: {
js: {
files: ['src/js/**/*.js'],
tasks: ['concat:js','concat:dev','strip_code','jshint']
},
scss: {
files: ['src/scss/**/*.scss'],
tasks: ['compass','concat:css']
}
},
concat: {
css: {
options: {
banner: '<%= banner %>',
separator: ''
},
files: {
'<%= dirs.build %>/mivhak.min.css': [
'<%= dirs.css %>/**/*.css'
]
}
},
js: {
options: {
separator: "",
banner: '<%= banner %>'
},
files: {
'<%= dirs.build %>/mivhak.js': [
'<%= dirs.js %>/intro.js',
'<%= dirs.js %>/ace.config.js',
'<%= dirs.js %>/utility.js',
'<%= dirs.js %>/jquery.template.js',
'<%= dirs.js %>/mivhak.js',
'<%= dirs.js %>/mivhak.defaults.js',
'<%= dirs.js %>/mivhak.resources.js',
'<%= dirs.js %>/mivhak.buttons.js',
'<%= dirs.js %>/mivhak.methods.js',
'<%= dirs.js %>/mivhak.icons.js',
'<%= dirs.js %>/mivhak.component.js',
'<%= dirs.js %>/components/*.js',
'<%= dirs.js %>/jquery.mivhak.js',
'<%= dirs.js %>/outro.js'
]
}
},
dev: {
files: {
'<%= dirs.build %>/mivhak-dev.js': ['<%= dirs.build %>/mivhak.js']
}
},
bundle: { // Create a version that includes all dependencies
files: {
'<%= dirs.build %>/mivhak.bundle.min.js': ['<%= dirs.js %>/lib/*.js','<%= dirs.build %>/mivhak.js']
}
}
},
compass: {
dist: {
options: {
sassDir: '<%= dirs.scss %>',
cssDir: '<%= dirs.css %>',
environment: 'production',
raw: 'preferred_syntax = :scss\n', // Use `raw` since it's not directly available
outputStyle: 'compressed'
}
}
},
jshint: {
all: ['Gruntfile.js', 'build/mivhak.js']
},
uglify: {
options: {
banner: '<%= banner %>'
},
dist: {
files: {
'<%= dirs.build %>/mivhak.min.js': ['<%= dirs.build %>/mivhak.js'],
'<%= dirs.build %>/mivhak.bundle.min.js': ['<%= dirs.build %>/mivhak.bundle.min.js']
}
}
},
strip_code: {
options: {
// Task-specific options go here.
},
your_target: {
src: 'build/mivhak.js'
},
},
components: {
dist: function() {
var src = '<%= dirs.js %>/components/*.js',
out = '<%= dirs.js %>/components/_compiled.js',
fileList = grunt.file.expand(grunt.template.process(src)),
contents = '';
fileList.forEach(function(file) {
var script = grunt.file.read(file),
template = (function() {
var src = file.replace('.js','.html');
if(grunt.file.exists(src)) return grunt.file.read(src).replace("\n"," ");
return '';
});
console.log(script,template);
contents += "\n(function(template){\n" + script + "\n})(`"+template+"`);\n";
});
// grunt.file.write(grunt.template.process(out),contents);
}
}
});
// Load grunt plugins
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-strip-code');
// Default task(s).
grunt.registerTask('build', ['concat:js','concat:dev','concat:bundle','strip_code','uglify','compass','concat:css','jshint']);
grunt.registerMultiTask("components", ["components"],function(){this.data.call();});
};