86ad6df667af5be81fd319b833cd0be723938f54
[Packages/TYPO3.CMS.git] / Build / Gruntfile.js
1 /*
2 * This file is part of the TYPO3 CMS project.
3 *
4 * It is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU General Public License, either version 2
6 * of the License, or any later version.
7 *
8 * For the full copyright and license information, please read the
9 * LICENSE.txt file that was distributed with this source code.
10 *
11 * The TYPO3 project - inspiring people to share!
12 */
13
14 module.exports = function(grunt) {
15
16 // Project configuration.
17 grunt.initConfig({
18 pkg: grunt.file.readJSON('package.json'),
19 banner: '/*!\n' +
20 ' * This file is part of the TYPO3 CMS project.\n' +
21 ' *\n' +
22 ' * It is free software; you can redistribute it and/or modify it under\n' +
23 ' * the terms of the GNU General Public License, either version 2\n' +
24 ' * of the License, or any later version.\n' +
25 ' *\n' +
26 ' * For the full copyright and license information, please read the\n' +
27 ' * LICENSE.txt file that was distributed with this source code.\n' +
28 ' *\n' +
29 ' * The TYPO3 project - inspiring people to share!\n' +
30 ' */\n',
31 paths: {
32 resources : 'Resources/',
33 less : '<%= paths.resources %>Public/Less/',
34 root : '../',
35 sysext : '<%= paths.root %>typo3/sysext/',
36 form : '<%= paths.sysext %>form/Resources/',
37 frontend : '<%= paths.sysext %>frontend/Resources/',
38 install : '<%= paths.sysext %>install/Resources/',
39 linkvalidator : '<%= paths.sysext %>linkvalidator/Resources/',
40 backend : '<%= paths.sysext %>backend/Resources/',
41 t3editor : '<%= paths.sysext %>t3editor/Resources/',
42 workspaces: '<%= paths.sysext %>workspaces/Resources/',
43 core : '<%= paths.sysext %>core/Resources/',
44 bower : 'bower_components/',
45 flags : '<%= paths.bower %>region-flags/svg/',
46 t3icons : '<%= paths.bower %>wmdbsystems-typo3-icons/dist/',
47 npm : 'node_modules/'
48 },
49 less: {
50 options: {
51 banner: '<%= banner %>',
52 outputSourceFiles: true
53 },
54 backend: {
55 files: {
56 "<%= paths.backend %>Public/Css/backend.css": "<%= paths.less %>backend.less"
57 }
58 },
59 core: {
60 files: {
61 "<%= paths.core %>Public/Css/errorpage.css": "<%= paths.less %>errorpage.less"
62 }
63 },
64 form: {
65 files: {
66 "<%= paths.form %>Public/Css/form.css": "<%= paths.less %>form.less"
67 }
68 },
69 frontend: {
70 files: {
71 "<%= paths.frontend %>Public/Css/adminpanel.css": "<%= paths.less %>adminpanel.less"
72 }
73 },
74 install: {
75 files: {
76 "<%= paths.install %>Public/Css/install.css": "<%= paths.less %>install.less"
77 }
78 },
79 linkvalidator: {
80 files: {
81 "<%= paths.linkvalidator %>Public/Css/linkvalidator.css": "<%= paths.less %>linkvalidator.less"
82 }
83 },
84 workspaces: {
85 files: {
86 "<%= paths.workspaces %>Public/Css/preview.css": "<%= paths.workspaces %>Private/Less/preview.less"
87 }
88 },
89 t3editor: {
90 files: {
91 '<%= paths.t3editor %>Public/Css/t3editor.css': '<%= paths.t3editor %>Private/Less/t3editor.less',
92 '<%= paths.t3editor %>Public/Css/t3editor_inner.css': '<%= paths.t3editor %>Private/Less/t3editor_inner.less',
93 '<%= paths.t3editor %>Public/Css/t3editor_typoscript_colors.css': '<%= paths.t3editor %>Private/Less/t3editor_typoscript_colors.less'
94 }
95 }
96 },
97 postcss: {
98 options: {
99 map: false,
100 processors: [
101 require('autoprefixer')({ // add vendor prefixes
102 browsers: [
103 'Last 2 versions',
104 'Firefox ESR',
105 'IE 11'
106 ]
107 })
108 ]
109 },
110 backend: {
111 src: '<%= paths.backend %>Public/Css/*.css'
112 },
113 core: {
114 src: '<%= paths.core %>Public/Css/*.css'
115 },
116 form: {
117 src: '<%= paths.form %>Public/Css/*.css'
118 },
119 frontend: {
120 src: '<%= paths.frontend %>Public/Css/*.css'
121 },
122 install: {
123 src: '<%= paths.install %>Public/Css/*.css'
124 },
125 linkvalidator: {
126 src: '<%= paths.linkvalidator %>Public/Css/*.css'
127 },
128 t3editor: {
129 src: '<%= paths.t3editor %>Public/Css/*.css'
130 },
131 workspaces: {
132 src: '<%= paths.workspaces %>Public/Css/*.css'
133 }
134 },
135 watch: {
136 options: {
137 livereload: true
138 },
139 less: {
140 files: '<%= paths.less %>**/*.less',
141 tasks: 'css'
142 }
143 },
144 copy: {
145 options: {
146 punctuation: ''
147 },
148 core_icons: {
149 files: [{
150 expand: true,
151 cwd: '<%= paths.t3icons %>',
152 src: ['**/*.svg', '!module/*'],
153 dest: '<%= paths.sysext %>core/Resources/Public/Icons/T3Icons/',
154 ext: '.svg'
155 }]
156 },
157 module_icons: {
158 files: [
159 { dest: '<%= paths.sysext %>about/Resources/Public/Icons/module-about.svg', src: '<%= paths.t3icons %>module/module-about.svg' },
160 { dest: '<%= paths.sysext %>belog/Resources/Public/Icons/module-belog.svg', src: '<%= paths.t3icons %>module/module-belog.svg' },
161 { dest: '<%= paths.sysext %>beuser/Resources/Public/Icons/module-beuser.svg', src: '<%= paths.t3icons %>module/module-beuser.svg' },
162 { dest: '<%= paths.sysext %>lowlevel/Resources/Public/Icons/module-config.svg', src: '<%= paths.t3icons %>module/module-config.svg' },
163 { dest: '<%= paths.sysext %>cshmanual/Resources/Public/Icons/module-cshmanual.svg', src: '<%= paths.t3icons %>module/module-cshmanual.svg' },
164 { dest: '<%= paths.sysext %>lowlevel/Resources/Public/Icons/module-dbint.svg', src: '<%= paths.t3icons %>module/module-dbint.svg' },
165 { dest: '<%= paths.sysext %>documentation/Resources/Public/Icons/module-documentation.svg', src: '<%= paths.t3icons %>module/module-documentation.svg' },
166 { dest: '<%= paths.sysext %>extensionmanager/Resources/Public/Icons/module-extensionmanager.svg', src: '<%= paths.t3icons %>module/module-extensionmanager.svg' },
167 { dest: '<%= paths.sysext %>filelist/Resources/Public/Icons/module-filelist.svg', src: '<%= paths.t3icons %>module/module-filelist.svg' },
168 { dest: '<%= paths.sysext %>func/Resources/Public/Icons/module-func.svg', src: '<%= paths.t3icons %>module/module-func.svg' },
169 { dest: '<%= paths.sysext %>indexed_search/Resources/Public/Icons/module-indexed_search.svg', src: '<%= paths.t3icons %>module/module-indexed_search.svg' },
170 { dest: '<%= paths.sysext %>info/Resources/Public/Icons/module-info.svg', src: '<%= paths.t3icons %>module/module-info.svg' },
171 { dest: '<%= paths.sysext %>install/Resources/Public/Icons/module-install.svg', src: '<%= paths.t3icons %>module/module-install.svg' },
172 { dest: '<%= paths.sysext %>lang/Resources/Public/Icons/module-lang.svg', src: '<%= paths.t3icons %>module/module-lang.svg' },
173 { dest: '<%= paths.sysext %>recordlist/Resources/Public/Icons/module-list.svg', src: '<%= paths.t3icons %>module/module-list.svg' },
174 { dest: '<%= paths.sysext %>backend/Resources/Public/Icons/module-page.svg', src: '<%= paths.t3icons %>module/module-page.svg' },
175 { dest: '<%= paths.sysext %>beuser/Resources/Public/Icons/module-permission.svg', src: '<%= paths.t3icons %>module/module-permission.svg' },
176 { dest: '<%= paths.sysext %>recycler/Resources/Public/Icons/module-recycler.svg', src: '<%= paths.t3icons %>module/module-recycler.svg' },
177 { dest: '<%= paths.sysext %>reports/Resources/Public/Icons/module-reports.svg', src: '<%= paths.t3icons %>module/module-reports.svg' },
178 { dest: '<%= paths.sysext %>scheduler/Resources/Public/Icons/module-scheduler.svg', src: '<%= paths.t3icons %>module/module-scheduler.svg' },
179 { dest: '<%= paths.sysext %>setup/Resources/Public/Icons/module-setup.svg', src: '<%= paths.t3icons %>module/module-setup.svg' },
180 { dest: '<%= paths.sysext %>taskcenter/Resources/Public/Icons/module-taskcenter.svg', src: '<%= paths.t3icons %>module/module-taskcenter.svg' },
181 { dest: '<%= paths.sysext %>tstemplate/Resources/Public/Icons/module-tstemplate.svg', src: '<%= paths.t3icons %>module/module-tstemplate.svg' },
182 { dest: '<%= paths.sysext %>version/Resources/Public/Icons/module-version.svg', src: '<%= paths.t3icons %>module/module-version.svg' },
183 { dest: '<%= paths.sysext %>viewpage/Resources/Public/Icons/module-viewpage.svg', src: '<%= paths.t3icons %>module/module-viewpage.svg' },
184 { dest: '<%= paths.sysext %>workspaces/Resources/Public/Icons/module-workspaces.svg', src: '<%= paths.t3icons %>module/module-workspaces.svg' }
185 ]
186 },
187 npm: {
188 files: [
189 {dest: '<%= paths.install %>Public/JavaScript/tagsort.min.js', src: '<%= paths.npm %>tagsort/tagsort.js'}
190 ]
191 }
192 },
193 bowercopy: {
194 options: {
195 clean: false,
196 report: false,
197 runBower: false,
198 srcPrefix: "bower_components/"
199 },
200 glob: {
201 files: {
202 // When using glob patterns, destinations are *always* folder names
203 // into which matching files will be copied
204 // Also note that subdirectories are **not** maintained
205 // if a destination is specified
206 // For example, one of the files copied here is
207 // 'lodash/dist/lodash.js' -> 'public/js/libs/lodash/lodash.js'
208 '<%= paths.sysext %>core/Resources/Public/Images/colorpicker': 'jquery-minicolors/*.png'
209 }
210 },
211 all: {
212 options: {
213 destPrefix: "<%= paths.core %>Public/JavaScript/Contrib"
214 },
215 files: {
216 'nprogress.js': 'nprogress/nprogress.js',
217 'jquery.matchHeight-min.js': 'matchHeight/jquery.matchHeight-min.js',
218 'jquery.dataTables.js': 'datatables/media/js/jquery.dataTables.min.js',
219 'require.js': 'requirejs/require.js',
220 'moment.js': 'moment/min/moment-with-locales.min.js',
221 'moment-timezone.js': 'moment-timezone/builds/moment-timezone-with-data.min.js',
222 'cropper.min.js': 'cropper/dist/cropper.min.js',
223 'imagesloaded.pkgd.min.js': 'imagesloaded/imagesloaded.pkgd.min.js',
224 'bootstrap-datetimepicker.js': 'eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js',
225 'autosize.js': 'autosize/dist/autosize.min.js',
226 'taboverride.min.js': 'taboverride/build/output/taboverride.min.js',
227 'bootstrap-slider.min.js': 'seiyria-bootstrap-slider/dist/bootstrap-slider.min.js',
228 /* disabled until events are not bound to document only
229 see https://github.com/claviska/jquery-minicolors/issues/192
230 see https://github.com/claviska/jquery-minicolors/issues/206
231 'jquery.minicolors.js': 'jquery-minicolors/jquery.minicolors.min.js',
232 */
233 /* disabled until autocomplete groupBy is fixed by the author
234 see https://github.com/devbridge/jQuery-Autocomplete/pull/387
235 'jquery.autocomplete.js': 'devbridge-autocomplete/src/jquery.autocomplete.js',
236 */
237 'd3/d3.js': 'd3/d3.min.js',
238 /**
239 * copy needed parts of jquery
240 */
241 'jquery/jquery-2.2.3.js': 'jquery/dist/jquery.js',
242 'jquery/jquery-2.2.3.min.js': 'jquery/dist/jquery.min.js',
243 /**
244 * copy needed parts of jquery-ui
245 */
246 'jquery-ui/core.js': 'jquery-ui/ui/core.js',
247 'jquery-ui/draggable.js': 'jquery-ui/ui/draggable.js',
248 'jquery-ui/droppable.js': 'jquery-ui/ui/droppable.js',
249 'jquery-ui/mouse.js': 'jquery-ui/ui/mouse.js',
250 'jquery-ui/position.js': 'jquery-ui/ui/position.js',
251 'jquery-ui/resizable.js': 'jquery-ui/ui/resizable.js',
252 'jquery-ui/selectable.js': 'jquery-ui/ui/selectable.js',
253 'jquery-ui/sortable.js': 'jquery-ui/ui/sortable.js',
254 'jquery-ui/widget.js': 'jquery-ui/ui/widget.js'
255 }
256 }
257 },
258 uglify: {
259 thirdparty: {
260 files: {
261 "<%= paths.core %>Public/JavaScript/Contrib/require.js": ["<%= paths.core %>Public/JavaScript/Contrib/require.js"],
262 "<%= paths.core %>Public/JavaScript/Contrib/nprogress.js": ["<%= paths.core %>Public/JavaScript/Contrib/nprogress.js"],
263 "<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/core.js": ["<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/core.js"],
264 "<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/draggable.js": ["<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/draggable.js"],
265 "<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/droppable.js": ["<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/droppable.js"],
266 "<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/mouse.js": ["<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/mouse.js"],
267 "<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/position.js": ["<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/position.js"],
268 "<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/resizable.js": ["<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/resizable.js"],
269 "<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/selectable.js": ["<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/selectable.js"],
270 "<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/sortable.js": ["<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/sortable.js"],
271 "<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/widget.js": ["<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/widget.js"],
272 "<%= paths.install %>Public/JavaScript/tagsort.min.js": ["<%= paths.install %>Public/JavaScript/tagsort.min.js"]
273 }
274 }
275 },
276 svgmin: {
277 options: {
278 plugins: [
279 { removeViewBox: false }
280 ]
281 },
282 // Flags
283 flags: {
284 files: [{
285 expand: true,
286 cwd: '<%= paths.flags %>',
287 src: '*.svg',
288 dest: '<%= paths.sysext %>core/Resources/Public/Icons/Flags/SVG/',
289 ext: '.svg',
290 extDot: 'first'
291 }]
292 }
293 }
294 });
295
296 // Register tasks
297 grunt.loadNpmTasks('grunt-contrib-less');
298 grunt.loadNpmTasks('grunt-contrib-watch');
299 grunt.loadNpmTasks('grunt-bowercopy');
300 grunt.loadNpmTasks('grunt-npm-install');
301 grunt.loadNpmTasks('grunt-bower-just-install');
302 grunt.loadNpmTasks('grunt-contrib-uglify');
303 grunt.loadNpmTasks('grunt-svgmin');
304 grunt.loadNpmTasks('grunt-postcss');
305 grunt.loadNpmTasks('grunt-contrib-copy');
306
307 /**
308 * grunt default task
309 *
310 * call "$ grunt"
311 *
312 * this will trigger the CSS build
313 */
314 grunt.registerTask('default', ['css']);
315
316 /**
317 * grunt css task
318 *
319 * call "$ grunt css"
320 *
321 * this task does the following things:
322 * - less
323 * - postcss
324 */
325 grunt.registerTask('css', ['less', 'postcss']);
326
327 /**
328 * grunt update task
329 *
330 * call "$ grunt update"
331 *
332 * this task does the following things:
333 * - npm install
334 * - bower install
335 * - copy some bower components to a specific destinations because they need to be included via PHP
336 */
337 grunt.registerTask('update', ['npm-install', 'bower_install', 'bowercopy']);
338
339 /**
340 * grunt build task
341 *
342 * call "$ grunt build"
343 *
344 * this task does the following things:
345 * - execute update task
346 * - execute copy task
347 * - compile less files
348 * - uglify js files
349 * - minifies svg files
350 */
351 grunt.registerTask('build', ['update', 'copy', 'css', 'uglify', 'svgmin']);
352 };