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