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