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