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