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