5dc29940850420619ce7a0ae6d6be4d41d1f24d5
[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 icons : '<%= paths.resources %>Private/Icons/',
35 root : '../',
36 sysext : '<%= paths.root %>typo3/sysext/',
37 t3skin : '<%= paths.sysext %>t3skin/Resources/',
38 backend : '<%= paths.sysext %>backend/Resources/',
39 core : '<%= paths.sysext %>core/Resources/'
40 },
41 less: {
42 t3skin: {
43 options: {
44 banner: '<%= banner %>',
45 outputSourceFiles: true
46 },
47 files: {
48 "<%= paths.t3skin %>Public/Css/backend.css": "<%= paths.less %>backend.less"
49 }
50 }
51 },
52 watch: {
53 less: {
54 files: '<%= paths.less %>**/*.less',
55 tasks: 'less'
56 }
57 },
58 bowercopy: {
59 options: {
60 clean: false,
61 report: false,
62 runBower: false,
63 srcPrefix: "bower_components/"
64 },
65 all: {
66 options: {
67 destPrefix: "<%= paths.core %>Public/JavaScript/Contrib"
68 },
69 files: {
70 'nprogress.js': 'nprogress/nprogress.js',
71 'jquery.dataTables.js': 'datatables/media/js/jquery.dataTables.min.js',
72 'require.js': 'requirejs/require.js',
73 'moment.js': 'moment/moment.js',
74 'cropper.min.js': 'cropper/dist/cropper.min.js',
75 'imagesloaded.pkgd.min.js': 'imagesloaded/imagesloaded.pkgd.min.js',
76 'bootstrap-datetimepicker.js': 'eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js',
77 'autosize.js': 'autosize/dest/autosize.min.js',
78 'placeholders.jquery.min.js': 'Placeholders.js/dist/placeholders.jquery.min.js',
79 'taboverride.min.js': 'taboverride/build/output/taboverride.min.js',
80 'bootstrap-slider.min.js': 'seiyria-bootstrap-slider/dist/bootstrap-slider.min.js',
81 /* disabled until autocomplete groupBy is fixed by the author
82 see https://github.com/devbridge/jQuery-Autocomplete/pull/387
83 'jquery.autocomplete.js': 'devbridge-autocomplete/src/jquery.autocomplete.js',
84 */
85
86 /**
87 * copy needed parts of jquery
88 */
89 'jquery/jquery-2.1.4.js': 'jquery/dist/jquery.js',
90 'jquery/jquery-2.1.4.min.js': 'jquery/dist/jquery.min.js',
91 /**
92 * copy needed parts of jquery-ui
93 */
94 'jquery-ui/core.js': 'jquery-ui/ui/core.js',
95 'jquery-ui/draggable.js': 'jquery-ui/ui/draggable.js',
96 'jquery-ui/droppable.js': 'jquery-ui/ui/droppable.js',
97 'jquery-ui/mouse.js': 'jquery-ui/ui/mouse.js',
98 'jquery-ui/position.js': 'jquery-ui/ui/position.js',
99 'jquery-ui/resizable.js': 'jquery-ui/ui/resizable.js',
100 'jquery-ui/selectable.js': 'jquery-ui/ui/selectable.js',
101 'jquery-ui/sortable.js': 'jquery-ui/ui/sortable.js',
102 'jquery-ui/widget.js': 'jquery-ui/ui/widget.js'
103 }
104 }
105 },
106 uglify: {
107 thirdparty: {
108 files: {
109 "<%= paths.core %>Public/JavaScript/Contrib/require.js": ["<%= paths.core %>Public/JavaScript/Contrib/require.js"],
110 "<%= paths.core %>Public/JavaScript/Contrib/moment.js": ["<%= paths.core %>Public/JavaScript/Contrib/moment.js"],
111 "<%= paths.core %>Public/JavaScript/Contrib/nprogress.js": ["<%= paths.core %>Public/JavaScript/Contrib/nprogress.js"],
112 "<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/core.js": ["<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/core.js"],
113 "<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/draggable.js": ["<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/draggable.js"],
114 "<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/droppable.js": ["<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/droppable.js"],
115 "<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/mouse.js": ["<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/mouse.js"],
116 "<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/position.js": ["<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/position.js"],
117 "<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/resizable.js": ["<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/resizable.js"],
118 "<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/selectable.js": ["<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/selectable.js"],
119 "<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/sortable.js": ["<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/sortable.js"],
120 "<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/widget.js": ["<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/widget.js"]
121 }
122 }
123 },
124 svgmin: {
125 options: {
126 plugins: [
127 { removeViewBox: false }
128 ]
129 },
130 // Action Icons
131 icons_action: {
132 files: {
133 '<%= paths.backend %>Public/Icons/Action/actions-document-paste-after.svg': '<%= paths.icons %>Action/actions-document-paste-after.svg',
134 '<%= paths.backend %>Public/Icons/Action/actions-document-paste-before.svg': '<%= paths.icons %>Action/actions-document-paste-before.svg',
135 '<%= paths.backend %>Public/Icons/Action/actions-document-paste-into.svg': '<%= paths.icons %>Action/actions-document-paste-into.svg',
136 '<%= paths.backend %>Public/Icons/Action/actions-document-paste.svg': '<%= paths.icons %>Action/actions-document-paste.svg',
137 '<%= paths.backend %>Public/Icons/Action/actions-document-save-cleartranslationcache.svg': '<%= paths.icons %>Action/actions-document-save-cleartranslationcache.svg',
138 '<%= paths.backend %>Public/Icons/Action/actions-document-save-close.svg': '<%= paths.icons %>Action/actions-document-save-close.svg',
139 '<%= paths.backend %>Public/Icons/Action/actions-document-save-new.svg': '<%= paths.icons %>Action/actions-document-save-new.svg',
140 '<%= paths.backend %>Public/Icons/Action/actions-document-save-translation.svg': '<%= paths.icons %>Action/actions-document-save-translation.svg',
141 '<%= paths.backend %>Public/Icons/Action/actions-document-save-view.svg': '<%= paths.icons %>Action/actions-document-save-view.svg',
142 '<%= paths.backend %>Public/Icons/Action/actions-document-save.svg': '<%= paths.icons %>Action/actions-document-save.svg',
143 '<%= paths.backend %>Public/Icons/Action/actions-filter.svg': '<%= paths.icons %>Action/actions-filter.svg',
144 '<%= paths.backend %>Public/Icons/Action/actions-page-new.svg': '<%= paths.icons %>Action/actions-page-new.svg',
145 '<%= paths.backend %>Public/Icons/Action/actions-page-move.svg': '<%= paths.icons %>Action/actions-page-move.svg',
146 '<%= paths.backend %>Public/Icons/Action/actions-page-open.svg': '<%= paths.icons %>Action/actions-page-open.svg',
147 '<%= paths.backend %>Public/Icons/Action/actions-refresh.svg': '<%= paths.icons %>Action/actions-refresh.svg',
148 '<%= paths.backend %>Public/Icons/Action/actions-search.svg': '<%= paths.icons %>Action/actions-search.svg',
149 '<%= paths.backend %>Public/Icons/Action/actions-system-cache-clear-impact-high.svg': '<%= paths.icons %>Action/actions-system-cache-clear-impact-high.svg',
150 '<%= paths.backend %>Public/Icons/Action/actions-system-cache-clear-impact-low.svg': '<%= paths.icons %>Action/actions-system-cache-clear-impact-low.svg',
151 '<%= paths.backend %>Public/Icons/Action/actions-system-cache-clear-impact-medium.svg': '<%= paths.icons %>Action/actions-system-cache-clear-impact-medium.svg',
152 '<%= paths.backend %>Public/Icons/Action/actions-system-help-open.svg': '<%= paths.icons %>Action/actions-system-help-open.svg',
153 '<%= paths.backend %>Public/Icons/Action/actions-system-tree-search-open.svg': '<%= paths.icons %>Action/actions-system-tree-search-open.svg'
154 }
155 },
156 // Action Icons
157 icons_apps: {
158 files: {
159 '<%= paths.backend %>Public/Icons/App/apps-pagetree-root.svg': '<%= paths.icons %>App/apps-pagetree-root.svg',
160 '<%= paths.backend %>Public/Icons/App/apps-toolbar-menu-search.svg': '<%= paths.icons %>App/apps-toolbar-menu-search.svg'
161 }
162 },
163 // Avatar Icons
164 icons_avatar: {
165 files: {
166 '<%= paths.sysext %>backend/Resources/Public/Icons/avatar-default.svg': '<%= paths.icons %>Avatar/avatar-default.svg'
167 }
168 },
169 // Default Icons
170 icons_default: {
171 files: {
172 '<%= paths.backend %>Public/Icons/Default/default-not-found.svg': '<%= paths.icons %>Default/default-not-found.svg'
173 }
174 },
175 // Miscellaneous Icons
176 icons_miscellaneous: {
177 files: {
178 '<%= paths.backend %>Public/Icons/Miscellaneous/miscellaneous-placeholder.svg': '<%= paths.icons %>Miscellaneous/miscellaneous-placeholder.svg'
179 }
180 },
181 // Module Icons
182 icons_module: {
183 files: {
184 '<%= paths.sysext %>about/Resources/Public/Icons/module-about.svg': '<%= paths.icons %>Module/module-about.svg',
185 '<%= paths.sysext %>aboutmodules/Resources/Public/Icons/module-aboutmodules.svg': '<%= paths.icons %>Module/module-aboutmodules.svg',
186 '<%= paths.sysext %>belog/Resources/Public/Icons/module-belog.svg': '<%= paths.icons %>Module/module-belog.svg',
187 '<%= paths.sysext %>beuser/Resources/Public/Icons/module-beuser.svg': '<%= paths.icons %>Module/module-beuser.svg',
188 '<%= paths.sysext %>lowlevel/Resources/Public/Icons/module-config.svg': '<%= paths.icons %>Module/module-config.svg',
189 '<%= paths.sysext %>cshmanual/Resources/Public/Icons/module-cshmanual.svg': '<%= paths.icons %>Module/module-cshmanual.svg',
190 '<%= paths.sysext %>dbal/Resources/Public/Icons/module-dbal.svg': '<%= paths.icons %>Module/module-dbal.svg',
191 '<%= paths.sysext %>lowlevel/Resources/Public/Icons/module-dbint.svg': '<%= paths.icons %>Module/module-dbint.svg',
192 '<%= paths.sysext %>documentation/Resources/Public/Icons/module-documentation.svg': '<%= paths.icons %>Module/module-documentation.svg',
193 '<%= paths.sysext %>extensionmanager/Resources/Public/Icons/module-extensionmanager.svg': '<%= paths.icons %>Module/module-extensionmanager.svg',
194 '<%= paths.sysext %>filelist/Resources/Public/Icons/module-filelist.svg': '<%= paths.icons %>Module/module-filelist.svg',
195 '<%= paths.sysext %>func/Resources/Public/Icons/module-func.svg': '<%= paths.icons %>Module/module-func.svg',
196 '<%= paths.sysext %>indexed_search/Resources/Public/Icons/module-indexed_search.svg': '<%= paths.icons %>Module/module-indexed_search.svg',
197 '<%= paths.sysext %>info/Resources/Public/Icons/module-info.svg': '<%= paths.icons %>Module/module-info.svg',
198 '<%= paths.sysext %>install/Resources/Public/Icons/module-install.svg': '<%= paths.icons %>Module/module-install.svg',
199 '<%= paths.sysext %>lang/Resources/Public/Icons/module-lang.svg': '<%= paths.icons %>Module/module-lang.svg',
200 '<%= paths.sysext %>recordlist/Resources/Public/Icons/module-list.svg': '<%= paths.icons %>Module/module-list.svg',
201 '<%= paths.sysext %>backend/Resources/Public/Icons/module-page.svg': '<%= paths.icons %>Module/module-page.svg',
202 '<%= paths.sysext %>beuser/Resources/Public/Icons/module-permission.svg': '<%= paths.icons %>Module/module-permission.svg',
203 '<%= paths.sysext %>recycler/Resources/Public/Icons/module-recycler.svg': '<%= paths.icons %>Module/module-recycler.svg',
204 '<%= paths.sysext %>reports/Resources/Public/Icons/module-reports.svg': '<%= paths.icons %>Module/module-reports.svg',
205 '<%= paths.sysext %>scheduler/Resources/Public/Icons/module-scheduler.svg': '<%= paths.icons %>Module/module-scheduler.svg',
206 '<%= paths.sysext %>setup/Resources/Public/Icons/module-setup.svg': '<%= paths.icons %>Module/module-setup.svg',
207 '<%= paths.sysext %>taskcenter/Resources/Public/Icons/module-taskcenter.svg': '<%= paths.icons %>Module/module-taskcenter.svg',
208 '<%= paths.sysext %>tstemplate/Resources/Public/Icons/module-tstemplate.svg': '<%= paths.icons %>Module/module-tstemplate.svg',
209 '<%= paths.sysext %>version/Resources/Public/Icons/module-version.svg': '<%= paths.icons %>Module/module-version.svg',
210 '<%= paths.sysext %>viewpage/Resources/Public/Icons/module-viewpage.svg': '<%= paths.icons %>Module/module-viewpage.svg',
211 '<%= paths.sysext %>workspaces/Resources/Public/Icons/module-workspaces.svg': '<%= paths.icons %>Module/module-workspaces.svg',
212 '<%= paths.sysext %>backend/Resources/Public/Icons/Spinner/spinner-circle-dark.svg': '<%= paths.icons %>Spinner/spinner-circle-dark.svg',
213 '<%= paths.sysext %>backend/Resources/Public/Icons/Spinner/spinner-circle-light.svg': '<%= paths.icons %>Spinner/spinner-circle-light.svg'
214 }
215 },
216 // Overlay Icons
217 icons_overlay: {
218 files: {
219 '<%= paths.backend %>Public/Icons/Overlay/overlay-deleted.svg': '<%= paths.icons %>Overlay/overlay-deleted.svg',
220 '<%= paths.backend %>Public/Icons/Overlay/overlay-hidden.svg': '<%= paths.icons %>Overlay/overlay-hidden.svg',
221 '<%= paths.backend %>Public/Icons/Overlay/overlay-includes-subpages.svg': '<%= paths.icons %>Overlay/overlay-includes-subpages.svg',
222 '<%= paths.backend %>Public/Icons/Overlay/overlay-locked.svg': '<%= paths.icons %>Overlay/overlay-locked.svg',
223 '<%= paths.backend %>Public/Icons/Overlay/overlay-readonly.svg': '<%= paths.icons %>Overlay/overlay-readonly.svg',
224 '<%= paths.backend %>Public/Icons/Overlay/overlay-restricted.svg': '<%= paths.icons %>Overlay/overlay-restricted.svg',
225 '<%= paths.backend %>Public/Icons/Overlay/overlay-scheduled.svg': '<%= paths.icons %>Overlay/overlay-scheduled.svg',
226 '<%= paths.backend %>Public/Icons/Overlay/overlay-translated.svg': '<%= paths.icons %>Overlay/overlay-translated.svg'
227 }
228 }
229 }
230 });
231
232 // Register tasks
233 grunt.loadNpmTasks('grunt-contrib-less');
234 grunt.loadNpmTasks('grunt-contrib-watch');
235 grunt.loadNpmTasks('grunt-bowercopy');
236 grunt.loadNpmTasks('grunt-npm-install');
237 grunt.loadNpmTasks('grunt-bower-just-install');
238 grunt.loadNpmTasks('grunt-contrib-uglify');
239 grunt.loadNpmTasks('grunt-svgmin');
240
241 /**
242 * grunt default task
243 *
244 * call "$ grunt"
245 *
246 * this will trigger the less build
247 */
248 grunt.registerTask('default', ['less']);
249
250 /**
251 * grunt update task
252 *
253 * call "$ grunt update"
254 *
255 * this task does the following things:
256 * - npn install
257 * - bower install
258 * - copy some bower components to a specific destinations because they need to be included via PHP
259 */
260 grunt.registerTask('update', ['npm-install', 'bower_install', 'bowercopy']);
261
262 /**
263 * grunt build task
264 *
265 * call "$ grunt build"
266 *
267 * this task does the following things:
268 * - execute update task
269 * - compile less files
270 * - uglify js files
271 * - minifies svg files
272 */
273 grunt.registerTask('build', ['update', 'less', 'uglify', 'svgmin']);
274 };