]> git.immae.eu Git - github/wallabag/wallabag.git/blob - Gruntfile.js
Add eslint & stylelint tests (fix a few things) and move dependencies to dev
[github/wallabag/wallabag.git] / Gruntfile.js
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 baggyfonts: {
127 files: [
128 {
129 expand: true,
130 cwd: '<%= modulesDir %>/icomoon-free-npm/Font',
131 src: 'IcoMoon-Free.ttf',
132 dest: '<%= releaseDir %>/themes/baggy/fonts/',
133 },
134 {
135 expand: true,
136 cwd: '<%= modulesDir %>/ptsans-npm-webfont/fonts',
137 src: 'ptsansbold.woff',
138 dest: '<%= releaseDir %>/themes/baggy/fonts/',
139 },
140 {
141 expand: true,
142 cwd: '<%= modulesDir %>/material-design-icons-iconfont/dist/fonts/',
143 src: ['MaterialIcons-Regular.eot', 'MaterialIcons-Regular.woff2', 'MaterialIcons-Regular.woff', 'MaterialIcons-Regular.ttf'],
144 dest: '<%= releaseDir %>/themes/baggy/fonts/',
145 },
146 ],
147 },
148 materialfonts: {
149 files: [
150 {
151 expand: true,
152 overwrite: true,
153 cwd: '<%= modulesDir %>/icomoon-free-npm/Font',
154 src: 'IcoMoon-Free.ttf',
155 dest: '<%= releaseDir %>/themes/material/fonts',
156 },
157 {
158 expand: true,
159 overwrite: true,
160 cwd: '<%= modulesDir %>/roboto-fontface/fonts/Roboto',
161 src: '*',
162 dest: '<%= releaseDir %>/themes/material/font/roboto',
163 },
164 {
165 expand: true,
166 overwrite: true,
167 cwd: '<%= modulesDir %>/material-design-icons-iconfont/dist/fonts/',
168 src: ['MaterialIcons-Regular.eot', 'MaterialIcons-Regular.woff2', 'MaterialIcons-Regular.woff', 'MaterialIcons-Regular.ttf'],
169 dest: '<%= releaseDir %>/themes/material/fonts/',
170 },
171 ],
172 },
173 },
174 symlink: {
175 pics: {
176 files: [
177 {
178 expand: true,
179 overwrite: true,
180 cwd: '<%= appDir %>/themes/_global/',
181 src: 'img',
182 dest: '<%= releaseDir %>/themes/_global/',
183 },
184 ],
185 },
186 },
187 clean: {
188 css: {
189 src: ['<%= buildDir %>/**/*.css'],
190 },
191 js: {
192 src: ['<%= buildDir %>/**/*.js', '<%= buildDir %>/**/*.map'],
193 },
194 all: {
195 src: ['./<%= buildDir %>'],
196 },
197 release: {
198 src: ['./<%= releaseDir %>/*'],
199 }
200 },
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
208 });
209
210 grunt.registerTask(
211 'fonts',
212 'Install fonts',
213 ['copy:baggyfonts', 'copy:materialfonts']
214 );
215
216 grunt.registerTask(
217 'js',
218 'Build and install js files',
219 ['clean:js', 'copy:pickerjs', 'browserify', 'uglify']
220 );
221
222 grunt.registerTask(
223 'default',
224 'Build and install everything',
225 ['clean', 'copy:pickerjs', 'concat', 'browserify', 'uglify', 'postcss', 'copy', 'symlink']
226 );
227
228 grunt.registerTask(
229 'css',
230 'Compiles the stylesheets.',
231 ['clean:css', 'concat:cssMaterial', 'concat:cssBaggy', 'postcss']
232 );
233
234 grunt.registerTask(
235 'tests',
236 'Test css and js style conformity',
237 ['eslint', 'stylelint']
238 )
239 };