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