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