1 | module.exports = function(grunt) { |
||
2 | grunt.initConfig({ |
||
3 | pkg: grunt.file.readJSON('package.json'), |
||
4 | banner: grunt.file.read('banner.js'), |
||
5 | dirs: { |
||
6 | scss: "src/scss", |
||
7 | css: "src/css", |
||
8 | js: "src/js", |
||
9 | demo: "demo", |
||
10 | build: "build" |
||
11 | }, |
||
12 | watch: { |
||
13 | js: { |
||
14 | files: ['src/js/**/*.js'], |
||
15 | tasks: ['concat:js','concat:dev','strip_code','jshint'] |
||
16 | }, |
||
17 | scss: { |
||
18 | files: ['src/scss/**/*.scss'], |
||
19 | tasks: ['compass','concat:css'] |
||
20 | } |
||
21 | }, |
||
22 | concat: { |
||
23 | css: { |
||
24 | options: { |
||
25 | banner: '<%= banner %>', |
||
26 | separator: '' |
||
27 | }, |
||
28 | files: { |
||
29 | '<%= dirs.build %>/mivhak.min.css': [ |
||
30 | '<%= dirs.css %>/**/*.css' |
||
31 | ] |
||
32 | } |
||
33 | }, |
||
34 | js: { |
||
35 | options: { |
||
36 | separator: "", |
||
37 | banner: '<%= banner %>' |
||
38 | }, |
||
39 | files: { |
||
40 | '<%= dirs.build %>/mivhak.js': [ |
||
41 | '<%= dirs.js %>/intro.js', |
||
42 | '<%= dirs.js %>/ace.config.js', |
||
43 | '<%= dirs.js %>/utility.js', |
||
44 | '<%= dirs.js %>/jquery.template.js', |
||
45 | '<%= dirs.js %>/mivhak.js', |
||
46 | '<%= dirs.js %>/mivhak.defaults.js', |
||
47 | '<%= dirs.js %>/mivhak.resources.js', |
||
48 | '<%= dirs.js %>/mivhak.buttons.js', |
||
49 | '<%= dirs.js %>/mivhak.methods.js', |
||
50 | '<%= dirs.js %>/mivhak.icons.js', |
||
51 | '<%= dirs.js %>/mivhak.component.js', |
||
52 | '<%= dirs.js %>/components/*.js', |
||
53 | '<%= dirs.js %>/jquery.mivhak.js', |
||
54 | '<%= dirs.js %>/outro.js' |
||
55 | ] |
||
56 | } |
||
57 | }, |
||
58 | dev: { |
||
59 | files: { |
||
60 | '<%= dirs.build %>/mivhak-dev.js': ['<%= dirs.build %>/mivhak.js'] |
||
61 | } |
||
62 | }, |
||
63 | bundle: { // Create a version that includes all dependencies |
||
64 | files: { |
||
65 | '<%= dirs.build %>/mivhak.bundle.min.js': ['<%= dirs.js %>/lib/*.js','<%= dirs.build %>/mivhak.js'] |
||
66 | } |
||
67 | } |
||
68 | }, |
||
69 | compass: { |
||
70 | dist: { |
||
71 | options: { |
||
72 | sassDir: '<%= dirs.scss %>', |
||
73 | cssDir: '<%= dirs.css %>', |
||
74 | environment: 'production', |
||
75 | raw: 'preferred_syntax = :scss\n', // Use `raw` since it's not directly available |
||
76 | outputStyle: 'compressed' |
||
77 | } |
||
78 | } |
||
79 | }, |
||
80 | jshint: { |
||
81 | all: ['Gruntfile.js', 'build/mivhak.js'] |
||
82 | }, |
||
83 | uglify: { |
||
84 | options: { |
||
85 | banner: '<%= banner %>' |
||
86 | }, |
||
87 | dist: { |
||
88 | files: { |
||
89 | '<%= dirs.build %>/mivhak.min.js': ['<%= dirs.build %>/mivhak.js'], |
||
90 | '<%= dirs.build %>/mivhak.bundle.min.js': ['<%= dirs.build %>/mivhak.bundle.min.js'] |
||
91 | } |
||
92 | } |
||
93 | }, |
||
94 | strip_code: { |
||
95 | options: { |
||
96 | // Task-specific options go here. |
||
97 | }, |
||
98 | your_target: { |
||
99 | src: 'build/mivhak.js' |
||
100 | }, |
||
101 | }, |
||
102 | components: { |
||
103 | dist: function() { |
||
104 | var src = '<%= dirs.js %>/components/*.js', |
||
105 | out = '<%= dirs.js %>/components/_compiled.js', |
||
0 ignored issues
–
show
Unused Code
introduced
by
![]() |
|||
106 | fileList = grunt.file.expand(grunt.template.process(src)), |
||
107 | contents = ''; |
||
108 | |||
109 | fileList.forEach(function(file) { |
||
110 | var script = grunt.file.read(file), |
||
111 | template = (function() { |
||
112 | var src = file.replace('.js','.html'); |
||
113 | if(grunt.file.exists(src)) return grunt.file.read(src).replace("\n"," "); |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed. ![]() |
|||
114 | return ''; |
||
115 | }); |
||
116 | |||
117 | console.log(script,template); |
||
0 ignored issues
–
show
|
|||
118 | contents += "\n(function(template){\n" + script + "\n})(`"+template+"`);\n"; |
||
119 | }); |
||
120 | |||
121 | // grunt.file.write(grunt.template.process(out),contents); |
||
122 | } |
||
123 | } |
||
124 | }); |
||
125 | |||
126 | // Load grunt plugins |
||
127 | grunt.loadNpmTasks('grunt-contrib-uglify'); |
||
128 | grunt.loadNpmTasks('grunt-contrib-compass'); |
||
129 | grunt.loadNpmTasks('grunt-contrib-concat'); |
||
130 | grunt.loadNpmTasks('grunt-contrib-watch'); |
||
131 | grunt.loadNpmTasks('grunt-contrib-jshint'); |
||
132 | grunt.loadNpmTasks('grunt-strip-code'); |
||
133 | |||
134 | // Default task(s). |
||
135 | grunt.registerTask('build', ['concat:js','concat:dev','concat:bundle','strip_code','uglify','compass','concat:css','jshint']); |
||
136 | grunt.registerMultiTask("components", ["components"],function(){this.data.call();}); |
||
137 | }; |