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