b10c48bc672e01b04855001bb18d2f7e8370a190
[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-search.svg': '<%= paths.icons %>Action/actions-search.svg',
148 '<%= paths.backend %>Public/Icons/Action/actions-system-cache-clear-impact-high.svg': '<%= paths.icons %>Action/actions-system-cache-clear-impact-high.svg',
149 '<%= paths.backend %>Public/Icons/Action/actions-system-cache-clear-impact-low.svg': '<%= paths.icons %>Action/actions-system-cache-clear-impact-low.svg',
150 '<%= paths.backend %>Public/Icons/Action/actions-system-cache-clear-impact-medium.svg': '<%= paths.icons %>Action/actions-system-cache-clear-impact-medium.svg',
151 '<%= paths.backend %>Public/Icons/Action/actions-system-help-open.svg': '<%= paths.icons %>Action/actions-system-help-open.svg',
152 '<%= paths.backend %>Public/Icons/Action/actions-system-tree-search-open.svg': '<%= paths.icons %>Action/actions-system-tree-search-open.svg'
153 }
154 },
155 // Action Icons
156 icons_apps: {
157 files: {
158 '<%= paths.backend %>Public/Icons/App/apps-pagetree-root.svg': '<%= paths.icons %>App/apps-pagetree-root.svg',
159 '<%= paths.backend %>Public/Icons/App/apps-toolbar-menu-search.svg': '<%= paths.icons %>App/apps-toolbar-menu-search.svg'
160 }
161 },
162 // Avatar Icons
163 icons_avatar: {
164 files: {
165 '<%= paths.sysext %>backend/Resources/Public/Icons/avatar-default.svg': '<%= paths.icons %>Avatar/avatar-default.svg'
166 }
167 },
168 // Miscellaneous Icons
169 icons_miscellaneous: {
170 files: {
171 '<%= paths.backend %>Public/Icons/Miscellaneous/miscellaneous-placeholder.svg': '<%= paths.icons %>Miscellaneous/miscellaneous-placeholder.svg'
172 }
173 },
174 // Module Icons
175 icons_module: {
176 files: {
177 '<%= paths.sysext %>about/Resources/Public/Icons/module-about.svg': '<%= paths.icons %>Module/module-about.svg',
178 '<%= paths.sysext %>aboutmodules/Resources/Public/Icons/module-aboutmodules.svg': '<%= paths.icons %>Module/module-aboutmodules.svg',
179 '<%= paths.sysext %>belog/Resources/Public/Icons/module-belog.svg': '<%= paths.icons %>Module/module-belog.svg',
180 '<%= paths.sysext %>beuser/Resources/Public/Icons/module-beuser.svg': '<%= paths.icons %>Module/module-beuser.svg',
181 '<%= paths.sysext %>lowlevel/Resources/Public/Icons/module-config.svg': '<%= paths.icons %>Module/module-config.svg',
182 '<%= paths.sysext %>cshmanual/Resources/Public/Icons/module-cshmanual.svg': '<%= paths.icons %>Module/module-cshmanual.svg',
183 '<%= paths.sysext %>dbal/Resources/Public/Icons/module-dbal.svg': '<%= paths.icons %>Module/module-dbal.svg',
184 '<%= paths.sysext %>lowlevel/Resources/Public/Icons/module-dbint.svg': '<%= paths.icons %>Module/module-dbint.svg',
185 '<%= paths.sysext %>documentation/Resources/Public/Icons/module-documentation.svg': '<%= paths.icons %>Module/module-documentation.svg',
186 '<%= paths.sysext %>extensionmanager/Resources/Public/Icons/module-extensionmanager.svg': '<%= paths.icons %>Module/module-extensionmanager.svg',
187 '<%= paths.sysext %>filelist/Resources/Public/Icons/module-filelist.svg': '<%= paths.icons %>Module/module-filelist.svg',
188 '<%= paths.sysext %>func/Resources/Public/Icons/module-func.svg': '<%= paths.icons %>Module/module-func.svg',
189 '<%= paths.sysext %>indexed_search/Resources/Public/Icons/module-indexed_search.svg': '<%= paths.icons %>Module/module-indexed_search.svg',
190 '<%= paths.sysext %>info/Resources/Public/Icons/module-info.svg': '<%= paths.icons %>Module/module-info.svg',
191 '<%= paths.sysext %>install/Resources/Public/Icons/module-install.svg': '<%= paths.icons %>Module/module-install.svg',
192 '<%= paths.sysext %>lang/Resources/Public/Icons/module-lang.svg': '<%= paths.icons %>Module/module-lang.svg',
193 '<%= paths.sysext %>recordlist/Resources/Public/Icons/module-list.svg': '<%= paths.icons %>Module/module-list.svg',
194 '<%= paths.sysext %>backend/Resources/Public/Icons/module-page.svg': '<%= paths.icons %>Module/module-page.svg',
195 '<%= paths.sysext %>beuser/Resources/Public/Icons/module-permission.svg': '<%= paths.icons %>Module/module-permission.svg',
196 '<%= paths.sysext %>recycler/Resources/Public/Icons/module-recycler.svg': '<%= paths.icons %>Module/module-recycler.svg',
197 '<%= paths.sysext %>reports/Resources/Public/Icons/module-reports.svg': '<%= paths.icons %>Module/module-reports.svg',
198 '<%= paths.sysext %>scheduler/Resources/Public/Icons/module-scheduler.svg': '<%= paths.icons %>Module/module-scheduler.svg',
199 '<%= paths.sysext %>setup/Resources/Public/Icons/module-setup.svg': '<%= paths.icons %>Module/module-setup.svg',
200 '<%= paths.sysext %>taskcenter/Resources/Public/Icons/module-taskcenter.svg': '<%= paths.icons %>Module/module-taskcenter.svg',
201 '<%= paths.sysext %>tstemplate/Resources/Public/Icons/module-tstemplate.svg': '<%= paths.icons %>Module/module-tstemplate.svg',
202 '<%= paths.sysext %>version/Resources/Public/Icons/module-version.svg': '<%= paths.icons %>Module/module-version.svg',
203 '<%= paths.sysext %>viewpage/Resources/Public/Icons/module-viewpage.svg': '<%= paths.icons %>Module/module-viewpage.svg',
204 '<%= paths.sysext %>workspaces/Resources/Public/Icons/module-workspaces.svg': '<%= paths.icons %>Module/module-workspaces.svg'
205 }
206 }
207 }
208 });
209
210 // Register tasks
211 grunt.loadNpmTasks('grunt-contrib-less');
212 grunt.loadNpmTasks('grunt-contrib-watch');
213 grunt.loadNpmTasks('grunt-bowercopy');
214 grunt.loadNpmTasks('grunt-npm-install');
215 grunt.loadNpmTasks('grunt-bower-just-install');
216 grunt.loadNpmTasks('grunt-contrib-uglify');
217 grunt.loadNpmTasks('grunt-svgmin');
218
219 /**
220 * grunt default task
221 *
222 * call "$ grunt"
223 *
224 * this will trigger the less build
225 */
226 grunt.registerTask('default', ['less']);
227
228 /**
229 * grunt update task
230 *
231 * call "$ grunt update"
232 *
233 * this task does the following things:
234 * - npn install
235 * - bower install
236 * - copy some bower components to a specific destinations because they need to be included via PHP
237 */
238 grunt.registerTask('update', ['npm-install', 'bower_install', 'bowercopy']);
239
240 /**
241 * grunt build task
242 *
243 * call "$ grunt build"
244 *
245 * this task does the following things:
246 * - execute update task
247 * - compile less files
248 * - uglify js files
249 * - minifies svg files
250 */
251 grunt.registerTask('build', ['update', 'less', 'uglify', 'svgmin']);
252 };