1f76d33dbce84f1e96a675675dcdc99fbb4deb50
[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 core : '<%= paths.sysext %>core/Resources/'
38 },
39 less: {
40 t3skin: {
41 options: {
42 banner: '<%= banner %>',
43 outputSourceFiles: true
44 },
45 files: {
46 "<%= paths.t3skin %>Public/Css/backend.css": "<%= paths.less %>backend.less"
47 }
48 }
49 },
50 watch: {
51 less: {
52 files: '<%= paths.less %>**/*.less',
53 tasks: 'less'
54 }
55 },
56 bowercopy: {
57 options: {
58 clean: false,
59 report: false,
60 runBower: false,
61 srcPrefix: "bower_components/"
62 },
63 all: {
64 options: {
65 destPrefix: "<%= paths.core %>Public/JavaScript/Contrib"
66 },
67 files: {
68 'nprogress.js': 'nprogress/nprogress.js',
69 'jquery.dataTables.js': 'datatables/media/js/jquery.dataTables.min.js',
70 'require.js': 'requirejs/require.js',
71 'moment.js': 'moment/moment.js',
72 'cropper.min.js': 'cropper/dist/cropper.min.js',
73 'imagesloaded.pkgd.min.js': 'imagesloaded/imagesloaded.pkgd.min.js',
74 'bootstrap-datetimepicker.js': 'eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js',
75 'autosize.js': 'autosize/dest/autosize.min.js',
76 'placeholders.jquery.min.js': 'Placeholders.js/dist/placeholders.jquery.min.js',
77 'taboverride.min.js': 'taboverride/build/output/taboverride.min.js',
78 'bootstrap-slider.min.js': 'seiyria-bootstrap-slider/dist/bootstrap-slider.min.js',
79 /* disabled until autocomplete groupBy is fixed by the author
80 see https://github.com/devbridge/jQuery-Autocomplete/pull/387
81 'jquery.autocomplete.js': 'devbridge-autocomplete/src/jquery.autocomplete.js',
82 */
83
84 /**
85 * copy needed parts of jquery
86 */
87 'jquery/jquery-2.1.4.js': 'jquery/dist/jquery.js',
88 'jquery/jquery-2.1.4.min.js': 'jquery/dist/jquery.min.js',
89 /**
90 * copy needed parts of jquery-ui
91 */
92 'jquery-ui/core.js': 'jquery-ui/ui/core.js',
93 'jquery-ui/draggable.js': 'jquery-ui/ui/draggable.js',
94 'jquery-ui/droppable.js': 'jquery-ui/ui/droppable.js',
95 'jquery-ui/mouse.js': 'jquery-ui/ui/mouse.js',
96 'jquery-ui/position.js': 'jquery-ui/ui/position.js',
97 'jquery-ui/resizable.js': 'jquery-ui/ui/resizable.js',
98 'jquery-ui/selectable.js': 'jquery-ui/ui/selectable.js',
99 'jquery-ui/sortable.js': 'jquery-ui/ui/sortable.js',
100 'jquery-ui/widget.js': 'jquery-ui/ui/widget.js'
101 }
102 }
103 },
104 copy: {
105 /**
106 * Copy icons into correct location
107 */
108 icons: {
109 files: [
110 // Avatar
111 { src: 'Resources/Private/Icons/avatar-default.svg', dest: '<%= paths.sysext %>backend/Resources/Public/Icons/avatar-default.svg' },
112 // Module Icons
113 { src: 'Resources/Private/Icons/module-about.svg', dest: '<%= paths.sysext %>about/Resources/Public/Icons/module-about.svg' },
114 { src: 'Resources/Private/Icons/module-aboutmodules.svg', dest: '<%= paths.sysext %>aboutmodules/Resources/Public/Icons/module-aboutmodules.svg' },
115 { src: 'Resources/Private/Icons/module-belog.svg', dest: '<%= paths.sysext %>belog/Resources/Public/Icons/module-belog.svg' },
116 { src: 'Resources/Private/Icons/module-beuser.svg', dest: '<%= paths.sysext %>beuser/Resources/Public/Icons/module-beuser.svg' },
117 { src: 'Resources/Private/Icons/module-config.svg', dest: '<%= paths.sysext %>lowlevel/Resources/Public/Icons/module-config.svg' },
118 { src: 'Resources/Private/Icons/module-cshmanual.svg', dest: '<%= paths.sysext %>cshmanual/Resources/Public/Icons/module-cshmanual.svg' },
119 { src: 'Resources/Private/Icons/module-dbal.svg', dest: '<%= paths.sysext %>dbal/Resources/Public/Icons/module-dbal.svg' },
120 { src: 'Resources/Private/Icons/module-dbint.svg', dest: '<%= paths.sysext %>lowlevel/Resources/Public/Icons/module-dbint.svg' },
121 { src: 'Resources/Private/Icons/module-documentation.svg', dest: '<%= paths.sysext %>documentation/Resources/Public/Icons/module-documentation.svg' },
122 { src: 'Resources/Private/Icons/module-extensionmanager.svg', dest: '<%= paths.sysext %>extensionmanager/Resources/Public/Icons/module-extensionmanager.svg' },
123 { src: 'Resources/Private/Icons/module-filelist.svg', dest: '<%= paths.sysext %>filelist/Resources/Public/Icons/module-filelist.svg' },
124 { src: 'Resources/Private/Icons/module-func.svg', dest: '<%= paths.sysext %>func/Resources/Public/Icons/module-func.svg' },
125 { src: 'Resources/Private/Icons/module-indexed_search.svg', dest: '<%= paths.sysext %>indexed_search/Resources/Public/Icons/module-indexed_search.svg' },
126 { src: 'Resources/Private/Icons/module-info.svg', dest: '<%= paths.sysext %>info/Resources/Public/Icons/module-info.svg' },
127 { src: 'Resources/Private/Icons/module-install.svg', dest: '<%= paths.sysext %>install/Resources/Public/Icons/module-install.svg' },
128 { src: 'Resources/Private/Icons/module-lang.svg', dest: '<%= paths.sysext %>lang/Resources/Public/Icons/module-lang.svg' },
129 { src: 'Resources/Private/Icons/module-list.svg', dest: '<%= paths.sysext %>recordlist/Resources/Public/Icons/module-list.svg' },
130 { src: 'Resources/Private/Icons/module-page.svg', dest: '<%= paths.sysext %>backend/Resources/Public/Icons/module-page.svg' },
131 { src: 'Resources/Private/Icons/module-permission.svg', dest: '<%= paths.sysext %>beuser/Resources/Public/Icons/module-permission.svg' },
132 { src: 'Resources/Private/Icons/module-recycler.svg', dest: '<%= paths.sysext %>recycler/Resources/Public/Icons/module-recycler.svg' },
133 { src: 'Resources/Private/Icons/module-reports.svg', dest: '<%= paths.sysext %>reports/Resources/Public/Icons/module-reports.svg' },
134 { src: 'Resources/Private/Icons/module-scheduler.svg', dest: '<%= paths.sysext %>scheduler/Resources/Public/Icons/module-scheduler.svg' },
135 { src: 'Resources/Private/Icons/module-setup.svg', dest: '<%= paths.sysext %>setup/Resources/Public/Icons/module-setup.svg' },
136 { src: 'Resources/Private/Icons/module-taskcenter.svg', dest: '<%= paths.sysext %>taskcenter/Resources/Public/Icons/module-taskcenter.svg' },
137 { src: 'Resources/Private/Icons/module-tstemplate.svg', dest: '<%= paths.sysext %>tstemplate/Resources/Public/Icons/module-tstemplate.svg' },
138 { src: 'Resources/Private/Icons/module-version.svg', dest: '<%= paths.sysext %>version/Resources/Public/Icons/module-version.svg' },
139 { src: 'Resources/Private/Icons/module-viewpage.svg', dest: '<%= paths.sysext %>viewpage/Resources/Public/Icons/module-viewpage.svg' },
140 { src: 'Resources/Private/Icons/module-workspaces.svg', dest: '<%= paths.sysext %>workspaces/Resources/Public/Icons/module-workspaces.svg' }
141 ]
142 }
143 },
144 uglify: {
145 my_target: {
146 files: {
147 "<%= paths.core %>Public/JavaScript/Contrib/require.js": ["<%= paths.core %>Public/JavaScript/Contrib/require.js"],
148 "<%= paths.core %>Public/JavaScript/Contrib/moment.js": ["<%= paths.core %>Public/JavaScript/Contrib/moment.js"],
149 "<%= paths.core %>Public/JavaScript/Contrib/nprogress.js": ["<%= paths.core %>Public/JavaScript/Contrib/nprogress.js"],
150 "<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/core.js": ["<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/core.js"],
151 "<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/draggable.js": ["<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/draggable.js"],
152 "<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/droppable.js": ["<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/droppable.js"],
153 "<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/mouse.js": ["<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/mouse.js"],
154 "<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/position.js": ["<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/position.js"],
155 "<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/resizable.js": ["<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/resizable.js"],
156 "<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/selectable.js": ["<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/selectable.js"],
157 "<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/sortable.js": ["<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/sortable.js"],
158 "<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/widget.js": ["<%= paths.core %>Public/JavaScript/Contrib/jquery-ui/widget.js"]
159 }
160 }
161 }
162 });
163
164 // Register tasks
165 grunt.loadNpmTasks('grunt-contrib-less');
166 grunt.loadNpmTasks('grunt-contrib-watch');
167 grunt.loadNpmTasks('grunt-bowercopy');
168 grunt.loadNpmTasks('grunt-contrib-copy');
169 grunt.loadNpmTasks('grunt-npm-install');
170 grunt.loadNpmTasks('grunt-bower-just-install');
171 grunt.loadNpmTasks('grunt-contrib-uglify');
172
173 /**
174 * grunt default task
175 *
176 * call "$ grunt"
177 *
178 * this will trigger the less build
179 */
180 grunt.registerTask('default', ['less']);
181
182 /**
183 * grunt update task
184 *
185 * call "$ grunt update"
186 *
187 * this task does the following things:
188 * - npn install
189 * - bower install
190 * - copy some bower components to a specific destinations because they need to be included via PHP
191 * - uglify 3rd party JavaScript libraries
192 */
193 grunt.registerTask('update', ['npm-install', 'bower_install', 'bowercopy', 'uglify']);
194
195 /**
196 * grunt task to copy icons into correct location
197 */
198 grunt.registerTask('build', ['copy:icons']);
199 };