]>
Commit | Line | Data |
---|---|---|
1 | module.exports = function (grunt) { | |
2 | require('load-grunt-tasks')(grunt); | |
3 | ||
4 | grunt.initConfig({ | |
5 | appDir: 'app/Resources/static', | |
6 | buildDir: 'web/bundles/wallabagcore', | |
7 | modulesDir: 'node_modules', | |
8 | ||
9 | postcss: { | |
10 | material: { | |
11 | options: { | |
12 | map: { | |
13 | inline: false, | |
14 | }, | |
15 | ||
16 | processors: [ | |
17 | require('pixrem')(), | |
18 | require('autoprefixer')({ browsers: 'last 2 versions' }), | |
19 | require('cssnano')(), | |
20 | ], | |
21 | }, | |
22 | src: '<%= buildDir %>/material.css', | |
23 | dest: '<%= buildDir %>/themes/material/css/style.min.css', | |
24 | }, | |
25 | baggy: { | |
26 | options: { | |
27 | map: { | |
28 | inline: false, | |
29 | }, | |
30 | ||
31 | processors: [ | |
32 | require('pixrem')(), | |
33 | require('autoprefixer')({ browsers: 'last 2 versions' }), | |
34 | require('cssnano')(), | |
35 | ], | |
36 | }, | |
37 | src: '<%= buildDir %>/baggy.css', | |
38 | dest: '<%= buildDir %>/themes/baggy/css/style.min.css', | |
39 | }, | |
40 | }, | |
41 | concat: { | |
42 | options: { | |
43 | separator: ';', | |
44 | }, | |
45 | cssMaterial: { | |
46 | src: [ | |
47 | 'node_modules/materialize-css/bin/materialize.css', | |
48 | '<%= appDir %>/themes/material/css/*.css', | |
49 | ], | |
50 | dest: '<%= buildDir %>/material.css', | |
51 | }, | |
52 | cssBaggy: { | |
53 | src: [ | |
54 | '<%= appDir %>/themes/baggy/css/*.css', | |
55 | ], | |
56 | dest: '<%= buildDir %>/baggy.css', | |
57 | }, | |
58 | }, | |
59 | browserify: { | |
60 | dist: { | |
61 | files: { | |
62 | '<%= buildDir %>/material.browser.js': ['<%= appDir %>/themes/material/js/init.js'], | |
63 | '<%= buildDir %>/baggy.browser.js': ['<%= appDir %>/themes/baggy/js/init.js'] | |
64 | } | |
65 | }, | |
66 | options: { | |
67 | sourceType: "module", | |
68 | transform: [ | |
69 | ["babelify", { | |
70 | presets: ["es2015"] | |
71 | }], ["browserify-shim", { | |
72 | "jquery": { | |
73 | "exports": "$" | |
74 | }, | |
75 | "materialize": "materialize", | |
76 | "jquery-ui": { | |
77 | "depends": "jquery", | |
78 | "exports": null | |
79 | } | |
80 | }] | |
81 | ], | |
82 | browserifyOptions: { | |
83 | browser: { | |
84 | "jQuery": "./node_modules/jquery/dist/jquery.js", | |
85 | "jquery.tinydot": "./node_modules/jquery.tinydot/src/jquery.tinydot.js", | |
86 | "jquery.ui": "./node_modules/jquery-ui-browserify/dist/jquery-ui.js" | |
87 | } | |
88 | } | |
89 | } | |
90 | ||
91 | }, | |
92 | uglify: { | |
93 | material: { | |
94 | files: { | |
95 | '<%= buildDir %>/themes/material/js/material.min.js': | |
96 | ['<%= buildDir %>/material.browser.js'], | |
97 | }, | |
98 | options: { | |
99 | sourceMap: true, | |
100 | }, | |
101 | }, | |
102 | baggy: { | |
103 | files: { | |
104 | '<%= buildDir %>/themes/baggy/js/baggy.min.js': | |
105 | ['<%= buildDir %>/baggy.browser.js'], | |
106 | }, | |
107 | options: { | |
108 | sourceMap: true, | |
109 | }, | |
110 | }, | |
111 | }, | |
112 | copy: { | |
113 | pickerjs: { | |
114 | expand: true, | |
115 | cwd: '<%= modulesDir %>/pickadate/lib', | |
116 | src: 'picker.js', | |
117 | dest: '<%= buildDir %>', | |
118 | }, | |
119 | annotator: { | |
120 | expand: true, | |
121 | cwd: '<%= modulesDir %>/annotator/pkg', | |
122 | src: 'annotator.min.js', | |
123 | dest: '<%= buildDir %>/themes/_global/js/', | |
124 | }, | |
125 | }, | |
126 | symlink: { | |
127 | baggyfonts: { | |
128 | files: [ | |
129 | { | |
130 | expand: true, | |
131 | overwrite: true, | |
132 | cwd: '<%= modulesDir %>/icomoon-free-npm/Font', | |
133 | src: 'IcoMoon-Free.ttf', | |
134 | dest: '<%= buildDir %>/themes/baggy/fonts/', | |
135 | }, | |
136 | { | |
137 | expand: true, | |
138 | overwrite: true, | |
139 | cwd: '<%= modulesDir %>/ptsans-npm-webfont/fonts', | |
140 | src: '*', | |
141 | dest: '<%= buildDir %>/themes/baggy/fonts/', | |
142 | }, | |
143 | { | |
144 | expand: true, | |
145 | overwrite: true, | |
146 | cwd: '<%= modulesDir %>/material-design-icons-iconfont/dist/fonts/', | |
147 | src: '*', | |
148 | dest: '<%= buildDir %>/themes/baggy/fonts/', | |
149 | }, | |
150 | ], | |
151 | }, | |
152 | materialfonts: { | |
153 | files: [ | |
154 | { | |
155 | expand: true, | |
156 | overwrite: true, | |
157 | cwd: '<%= modulesDir %>/icomoon-free-npm/Font', | |
158 | src: 'IcoMoon-Free.ttf', | |
159 | dest: '<%= buildDir %>/themes/material/fonts', | |
160 | }, | |
161 | { | |
162 | expand: true, | |
163 | overwrite: true, | |
164 | cwd: '<%= modulesDir %>/materialize-css/', | |
165 | src: 'font', | |
166 | dest: '<%= buildDir %>/themes/material', | |
167 | }, | |
168 | { | |
169 | expand: true, | |
170 | overwrite: true, | |
171 | cwd: '<%= modulesDir %>/roboto-fontface/fonts/Roboto', | |
172 | src: '*', | |
173 | dest: '<%= buildDir %>/themes/material/fonts/', | |
174 | }, | |
175 | { | |
176 | expand: true, | |
177 | overwrite: true, | |
178 | cwd: '<%= modulesDir %>/material-design-icons-iconfont/dist/fonts/', | |
179 | src: '*', | |
180 | dest: '<%= buildDir %>/themes/material/fonts/', | |
181 | }, | |
182 | ], | |
183 | }, | |
184 | pics: { | |
185 | files: [ | |
186 | { | |
187 | expand: true, | |
188 | overwrite: true, | |
189 | cwd: '<%= appDir %>/themes/_global/', | |
190 | src: 'img', | |
191 | dest: '<%= buildDir %>/themes/_global/', | |
192 | }, | |
193 | ], | |
194 | }, | |
195 | }, | |
196 | clean: { | |
197 | css: { | |
198 | src: ['<%= buildDir %>/**/*.css'], | |
199 | }, | |
200 | js: { | |
201 | src: ['<%= buildDir %>/**/*.js', '<%= buildDir %>/**/*.map'], | |
202 | }, | |
203 | all: { | |
204 | src: ['./<%= buildDir %>'], | |
205 | }, | |
206 | }, | |
207 | }); | |
208 | ||
209 | grunt.registerTask( | |
210 | 'fonts', | |
211 | 'Install fonts', | |
212 | ['symlink:baggyfonts', 'symlink:materialfonts'] | |
213 | ); | |
214 | ||
215 | grunt.registerTask( | |
216 | 'js', | |
217 | 'Build and install js files', | |
218 | ['clean:js', 'copy:pickerjs', 'browserify', 'uglify'] | |
219 | ); | |
220 | ||
221 | grunt.registerTask( | |
222 | 'default', | |
223 | 'Build and install everything', | |
224 | ['clean', 'copy:pickerjs', 'concat', 'browserify', 'uglify', 'postcss', 'symlink'] | |
225 | ); | |
226 | ||
227 | grunt.registerTask( | |
228 | 'css', | |
229 | 'Compiles the stylesheets.', | |
230 | ['clean:css', 'concat:cssMaterial', 'concat:cssBaggy', 'postcss'] | |
231 | ); | |
232 | }; |