65b99fc1a5c0ba58e2622c2e7bd2b5c088781a27
[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 t3skin : '<%= paths.sysext %>t3skin/Resources/',
37 form : '<%= paths.sysext %>form/Resources/',
38 frontend : '<%= paths.sysext %>frontend/Resources/',
39 install : '<%= paths.sysext %>install/Resources/',
40 linkvalidator : '<%= paths.sysext %>linkvalidator/Resources/',
41 backend : '<%= paths.sysext %>backend/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 t3skin: {
52 files: {
53 "<%= paths.t3skin %>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 },
82 postcss: {
83 options: {
84 map: false,
85 processors: [
86 require('autoprefixer')({ // add vendor prefixes
87 browsers: [
88 'Last 2 versions',
89 'Firefox ESR',
90 'IE 11'
91 ]
92 })
93 ]
94 },
95 t3skin: {
96 src: '<%= paths.t3skin %>Public/Css/*.css'
97 },
98 core: {
99 src: '<%= paths.core %>Public/Css/*.css'
100 },
101 form: {
102 src: '<%= paths.form %>Public/Css/*.css'
103 },
104 frontend: {
105 src: '<%= paths.frontend %>Public/Css/*.css'
106 },
107 install: {
108 src: '<%= paths.install %>Public/Css/*.css'
109 },
110 linkvalidator: {
111 src: '<%= paths.linkvalidator %>Public/Css/*.css'
112 }
113 },
114 watch: {
115 less: {
116 files: '<%= paths.less %>**/*.less',
117 tasks: 'css'
118 }
119 },
120 copy: {
121 options: {
122 punctuation: ''
123 },
124 core_icons: {
125 files: [{
126 expand: true,
127 cwd: '<%= paths.t3icons %>',
128 src: ['**/*.svg', '!module/*'],
129 dest: '<%= paths.sysext %>core/Resources/Public/Icons/T3Icons/',
130 ext: '.svg'
131 }]
132 },
133 module_icons: {
134 files: [
135 { dest: '<%= paths.sysext %>about/Resources/Public/Icons/module-about.svg', src: '<%= paths.t3icons %>module/module-about.svg' },
136 { dest: '<%= paths.sysext %>belog/Resources/Public/Icons/module-belog.svg', src: '<%= paths.t3icons %>module/module-belog.svg' },
137 { dest: '<%= paths.sysext %>beuser/Resources/Public/Icons/module-beuser.svg', src: '<%= paths.t3icons %>module/module-beuser.svg' },
138 { dest: '<%= paths.sysext %>lowlevel/Resources/Public/Icons/module-config.svg', src: '<%= paths.t3icons %>module/module-config.svg' },
139 { dest: '<%= paths.sysext %>cshmanual/Resources/Public/Icons/module-cshmanual.svg', src: '<%= paths.t3icons %>module/module-cshmanual.svg' },
140 { dest: '<%= paths.sysext %>dbal/Resources/Public/Icons/module-dbal.svg', src: '<%= paths.t3icons %>module/module-dbal.svg' },
141 { dest: '<%= paths.sysext %>lowlevel/Resources/Public/Icons/module-dbint.svg', src: '<%= paths.t3icons %>module/module-dbint.svg' },
142 { dest: '<%= paths.sysext %>documentation/Resources/Public/Icons/module-documentation.svg', src: '<%= paths.t3icons %>module/module-documentation.svg' },
143 { dest: '<%= paths.sysext %>extensionmanager/Resources/Public/Icons/module-extensionmanager.svg', src: '<%= paths.t3icons %>module/module-extensionmanager.svg' },
144 { dest: '<%= paths.sysext %>filelist/Resources/Public/Icons/module-filelist.svg', src: '<%= paths.t3icons %>module/module-filelist.svg' },
145 { dest: '<%= paths.sysext %>func/Resources/Public/Icons/module-func.svg', src: '<%= paths.t3icons %>module/module-func.svg' },
146 { dest: '<%= paths.sysext %>indexed_search/Resources/Public/Icons/module-indexed_search.svg', src: '<%= paths.t3icons %>module/module-indexed_search.svg' },
147 { dest: '<%= paths.sysext %>info/Resources/Public/Icons/module-info.svg', src: '<%= paths.t3icons %>module/module-info.svg' },
148 { dest: '<%= paths.sysext %>install/Resources/Public/Icons/module-install.svg', src: '<%= paths.t3icons %>module/module-install.svg' },
149 { dest: '<%= paths.sysext %>lang/Resources/Public/Icons/module-lang.svg', src: '<%= paths.t3icons %>module/module-lang.svg' },
150 { dest: '<%= paths.sysext %>recordlist/Resources/Public/Icons/module-list.svg', src: '<%= paths.t3icons %>module/module-list.svg' },
151 { dest: '<%= paths.sysext %>backend/Resources/Public/Icons/module-page.svg', src: '<%= paths.t3icons %>module/module-page.svg' },
152 { dest: '<%= paths.sysext %>beuser/Resources/Public/Icons/module-permission.svg', src: '<%= paths.t3icons %>module/module-permission.svg' },
153 { dest: '<%= paths.sysext %>recycler/Resources/Public/Icons/module-recycler.svg', src: '<%= paths.t3icons %>module/module-recycler.svg' },
154 { dest: '<%= paths.sysext %>reports/Resources/Public/Icons/module-reports.svg', src: '<%= paths.t3icons %>module/module-reports.svg' },
155 { dest: '<%= paths.sysext %>scheduler/Resources/Public/Icons/module-scheduler.svg', src: '<%= paths.t3icons %>module/module-scheduler.svg' },
156 { dest: '<%= paths.sysext %>setup/Resources/Public/Icons/module-setup.svg', src: '<%= paths.t3icons %>module/module-setup.svg' },
157 { dest: '<%= paths.sysext %>taskcenter/Resources/Public/Icons/module-taskcenter.svg', src: '<%= paths.t3icons %>module/module-taskcenter.svg' },
158 { dest: '<%= paths.sysext %>tstemplate/Resources/Public/Icons/module-tstemplate.svg', src: '<%= paths.t3icons %>module/module-tstemplate.svg' },
159 { dest: '<%= paths.sysext %>version/Resources/Public/Icons/module-version.svg', src: '<%= paths.t3icons %>module/module-version.svg' },
160 { dest: '<%= paths.sysext %>viewpage/Resources/Public/Icons/module-viewpage.svg', src: '<%= paths.t3icons %>module/module-viewpage.svg' },
161 { dest: '<%= paths.sysext %>workspaces/Resources/Public/Icons/module-workspaces.svg', src: '<%= paths.t3icons %>module/module-workspaces.svg' }
162 ]
163 }
164 },
165 bowercopy: {
166 options: {
167 clean: false,
168 report: false,
169 runBower: false,
170 srcPrefix: "bower_components/"
171 },
172 all: {
173 options: {
174 destPrefix: "<%= paths.core %>Public/JavaScript/Contrib"
175 },
176 files: {
177 'nprogress.js': 'nprogress/nprogress.js',
178 'jquery.matchHeight-min.js': 'matchHeight/jquery.matchHeight-min.js',
179 'jquery.dataTables.js': 'datatables/media/js/jquery.dataTables.min.js',
180 'require.js': 'requirejs/require.js',
181 'moment.js': 'moment/moment.js',
182 'moment-timezone.js': 'moment-timezone/builds/moment-timezone-with-data.min.js',
183 'cropper.min.js': 'cropper/dist/cropper.min.js',
184 'imagesloaded.pkgd.min.js': 'imagesloaded/imagesloaded.pkgd.min.js',
185 'bootstrap-datetimepicker.js': 'eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js',
186 'autosize.js': 'autosize/dist/autosize.min.js',
187 'taboverride.min.js': 'taboverride/build/output/taboverride.min.js',
188 'bootstrap-slider.min.js': 'seiyria-bootstrap-slider/dist/bootstrap-slider.min.js',
189 /* disabled until autocomplete groupBy is fixed by the author
190 see https://github.com/devbridge/jQuery-Autocomplete/pull/387
191 'jquery.autocomplete.js': 'devbridge-autocomplete/src/jquery.autocomplete.js',
192 */
193
194 /**
195 * copy needed parts of jquery
196 */
197 'jquery/jquery-2.2.1.js': 'jquery/dist/jquery.js',
198 'jquery/jquery-2.2.1.min.js': 'jquery/dist/jquery.min.js',
199 /**
200 * copy needed parts of jquery-ui
201 */
202 'jquery-ui/core.js': 'jquery-ui/ui/core.js',
203 'jquery-ui/draggable.js': 'jquery-ui/ui/draggable.js',
204 'jquery-ui/droppable.js': 'jquery-ui/ui/droppable.js',
205 'jquery-ui/mouse.js': 'jquery-ui/ui/mouse.js',
206 'jquery-ui/position.js': 'jquery-ui/ui/position.js',
207 'jquery-ui/resizable.js': 'jquery-ui/ui/resizable.js',
208 'jquery-ui/selectable.js': 'jquery-ui/ui/selectable.js',
209 'jquery-ui/sortable.js': 'jquery-ui/ui/sortable.js',
210 'jquery-ui/widget.js': 'jquery-ui/ui/widget.js'
211 }
212 }
213 },
214 uglify: {
215 thirdparty: {
216 files: {
217 "<%= paths.core %>Public/JavaScript/Contrib/require.js": ["<%= paths.core %>Public/JavaScript/Contrib/require.js"],
218 "<%= paths.core %>Public/JavaScript/Contrib/moment.js": ["<%= paths.core %>Public/JavaScript/Contrib/moment.js"],
219 "<%= paths.core %>Public/JavaScript/Contrib/nprogress.js": ["<%= paths.core %>Public/JavaScript/Contrib/nprogress.js"],
220 "<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/core.js": ["<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/core.js"],
221 "<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/draggable.js": ["<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/draggable.js"],
222 "<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/droppable.js": ["<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/droppable.js"],
223 "<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/mouse.js": ["<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/mouse.js"],
224 "<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/position.js": ["<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/position.js"],
225 "<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/resizable.js": ["<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/resizable.js"],
226 "<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/selectable.js": ["<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/selectable.js"],
227 "<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/sortable.js": ["<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/sortable.js"],
228 "<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/widget.js": ["<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/widget.js"]
229 }
230 }
231 },
232 svgmin: {
233 options: {
234 plugins: [
235 { removeViewBox: false }
236 ]
237 },
238 // Flags
239 flags: {
240 files: [{
241 expand: true,
242 cwd: '<%= paths.flags %>',
243 src: '*.svg',
244 dest: '<%= paths.sysext %>core/Resources/Public/Icons/Flags/SVG/',
245 ext: '.svg',
246 extDot: 'first'
247 }]
248 }
249 }
250 });
251
252 // Register tasks
253 grunt.loadNpmTasks('grunt-contrib-less');
254 grunt.loadNpmTasks('grunt-contrib-watch');
255 grunt.loadNpmTasks('grunt-bowercopy');
256 grunt.loadNpmTasks('grunt-npm-install');
257 grunt.loadNpmTasks('grunt-bower-just-install');
258 grunt.loadNpmTasks('grunt-contrib-uglify');
259 grunt.loadNpmTasks('grunt-svgmin');
260 grunt.loadNpmTasks('grunt-postcss');
261 grunt.loadNpmTasks('grunt-copy');
262
263 /**
264 * grunt default task
265 *
266 * call "$ grunt"
267 *
268 * this will trigger the CSS build
269 */
270 grunt.registerTask('default', ['css']);
271
272 /**
273 * grunt css task
274 *
275 * call "$ grunt css"
276 *
277 * this task does the following things:
278 * - less
279 * - postcss
280 */
281 grunt.registerTask('css', ['less', 'postcss']);
282
283 /**
284 * grunt update task
285 *
286 * call "$ grunt update"
287 *
288 * this task does the following things:
289 * - npm install
290 * - bower install
291 * - copy some bower components to a specific destinations because they need to be included via PHP
292 */
293 grunt.registerTask('update', ['npm-install', 'bower_install', 'bowercopy']);
294
295 /**
296 * grunt build task
297 *
298 * call "$ grunt build"
299 *
300 * this task does the following things:
301 * - execute update task
302 * - execute copy task
303 * - compile less files
304 * - uglify js files
305 * - minifies svg files
306 */
307 grunt.registerTask('build', ['update', 'copy', 'css', 'uglify', 'svgmin']);
308 };