source: ether_iasi/trunk/web/resources/js/library/jquery-ui-1.10.4.custom/development-bundle/Gruntfile.js @ 786

Last change on this file since 786 was 786, checked in by cbipsl, 10 years ago

commit temp
bug libraries

File size: 5.5 KB
Line 
1module.exports = function( grunt ) {
2
3"use strict";
4
5var
6        // files
7        coreFiles = [
8                "jquery.ui.core.js",
9                "jquery.ui.widget.js",
10                "jquery.ui.mouse.js",
11                "jquery.ui.draggable.js",
12                "jquery.ui.droppable.js",
13                "jquery.ui.resizable.js",
14                "jquery.ui.selectable.js",
15                "jquery.ui.sortable.js",
16                "jquery.ui.effect.js"
17        ],
18
19        uiFiles = coreFiles.map(function( file ) {
20                return "ui/" + file;
21        }).concat( expandFiles( "ui/*.js" ).filter(function( file ) {
22                return coreFiles.indexOf( file.substring(3) ) === -1;
23        })),
24
25        allI18nFiles = expandFiles( "ui/i18n/*.js" ),
26
27        cssFiles = [
28                "core",
29                "accordion",
30                "autocomplete",
31                "button",
32                "datepicker",
33                "dialog",
34                "menu",
35                "progressbar",
36                "resizable",
37                "selectable",
38                "slider",
39                "spinner",
40                "tabs",
41                "tooltip",
42                "theme"
43        ].map(function( component ) {
44                return "themes/base/jquery.ui." + component + ".css";
45        }),
46
47        // minified files
48        minify = {
49                options: {
50                        preserveComments: false
51                },
52                main: {
53                        options: {
54                                banner: createBanner( uiFiles )
55                        },
56                        files: {
57                                "dist/jquery-ui.min.js": "dist/jquery-ui.js"
58                        }
59                },
60                i18n: {
61                        options: {
62                                banner: createBanner( allI18nFiles )
63                        },
64                        files: {
65                                "dist/i18n/jquery-ui-i18n.min.js": "dist/i18n/jquery-ui-i18n.js"
66                        }
67                }
68        },
69
70        minifyCSS = {
71                options: {
72                        keepSpecialComments: 0
73                },
74                main: {
75                        options: {
76                                keepSpecialComments: "*"
77                        },
78                        src: "dist/jquery-ui.css",
79                        dest: "dist/jquery-ui.min.css"
80                }
81        },
82
83        compareFiles = {
84                all: [
85                        "dist/jquery-ui.js",
86                        "dist/jquery-ui.min.js"
87                ]
88        };
89
90function mapMinFile( file ) {
91        return "dist/" + file.replace( /\.js$/, ".min.js" ).replace( /ui\//, "minified/" );
92}
93
94function expandFiles( files ) {
95        return grunt.util._.pluck( grunt.file.expandMapping( files ), "src" ).map(function( values ) {
96                return values[ 0 ];
97        });
98}
99
100uiFiles.concat( allI18nFiles ).forEach(function( file ) {
101        minify[ file ] = {
102                options: {
103                        banner: createBanner()
104                },
105                files: {}
106        };
107        minify[ file ].files[ mapMinFile( file ) ] = file;
108});
109
110cssFiles.forEach(function( file ) {
111        minifyCSS[ file ] = {
112                options: {
113                        banner: createBanner()
114                },
115                src: file,
116                dest: "dist/" + file.replace( /\.css$/, ".min.css" ).replace( /themes\/base\//, "themes/base/minified/" )
117        };
118});
119
120uiFiles.forEach(function( file ) {
121        // TODO this doesn't do anything until https://github.com/rwldrn/grunt-compare-size/issues/13
122        compareFiles[ file ] = [ file,  mapMinFile( file ) ];
123});
124
125// grunt plugins
126grunt.loadNpmTasks( "grunt-contrib-jshint" );
127grunt.loadNpmTasks( "grunt-contrib-uglify" );
128grunt.loadNpmTasks( "grunt-contrib-concat" );
129grunt.loadNpmTasks( "grunt-contrib-qunit" );
130grunt.loadNpmTasks( "grunt-contrib-csslint" );
131grunt.loadNpmTasks( "grunt-contrib-cssmin" );
132grunt.loadNpmTasks( "grunt-html" );
133grunt.loadNpmTasks( "grunt-compare-size" );
134grunt.loadNpmTasks( "grunt-git-authors" );
135// local testswarm and build tasks
136grunt.loadTasks( "build/tasks" );
137
138function stripDirectory( file ) {
139        return file.replace( /.+\/(.+?)>?$/, "$1" );
140}
141
142function createBanner( files ) {
143        // strip folders
144        var fileNames = files && files.map( stripDirectory );
145        return "/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - " +
146                "<%= grunt.template.today('isoDate') %>\n" +
147                "<%= pkg.homepage ? '* ' + pkg.homepage + '\\n' : '' %>" +
148                (files ? "* Includes: " + fileNames.join(", ") + "\n" : "")+
149                "* Copyright <%= grunt.template.today('yyyy') %> <%= pkg.author.name %>;" +
150                " Licensed <%= _.pluck(pkg.licenses, 'type').join(', ') %> */\n";
151}
152
153grunt.initConfig({
154        pkg: grunt.file.readJSON("package.json"),
155        files: {
156                dist: "<%= pkg.name %>-<%= pkg.version %>"
157        },
158        compare_size: compareFiles,
159        concat: {
160                ui: {
161                        options: {
162                                banner: createBanner( uiFiles ),
163                                stripBanners: {
164                                        block: true
165                                }
166                        },
167                        src: uiFiles,
168                        dest: "dist/jquery-ui.js"
169                },
170                i18n: {
171                        options: {
172                                banner: createBanner( allI18nFiles )
173                        },
174                        src: allI18nFiles,
175                        dest: "dist/i18n/jquery-ui-i18n.js"
176                },
177                css: {
178                        options: {
179                                banner: createBanner( cssFiles ),
180                                stripBanners: {
181                                        block: true
182                                }
183                        },
184                        src: cssFiles,
185                        dest: "dist/jquery-ui.css"
186                }
187        },
188        uglify: minify,
189        cssmin: minifyCSS,
190        htmllint: {
191                // ignore files that contain invalid html, used only for ajax content testing
192                all: grunt.file.expand( [ "demos/**/*.html", "tests/**/*.html" ] ).filter(function( file ) {
193                        return !/(?:ajax\/content\d\.html|tabs\/data\/test\.html|tests\/unit\/core\/core\.html)/.test( file );
194                })
195        },
196        copy: {
197                dist_units_images: {
198                        src: "themes/base/images/*",
199                        strip: /^themes\/base\//,
200                        dest: "dist/"
201                }
202        },
203        qunit: {
204                files: expandFiles( "tests/unit/**/*.html" ).filter(function( file ) {
205                        // disabling everything that doesn't (quite) work with PhantomJS for now
206                        // TODO except for all|index|test, try to include more as we go
207                        return !( /(all|index|test|dialog|dialog_deprecated|tooltip)\.html$/ ).test( file );
208                })
209        },
210        jshint: {
211                options: {
212                        jshintrc: true
213                },
214                all: [
215                        "ui/*.js",
216                        "Gruntfile.js",
217                        "build/**/*.js",
218                        "tests/unit/**/*.js"
219                ]
220        },
221        csslint: {
222                base_theme: {
223                        src: "themes/base/*.css",
224                        options: {
225                                csslintrc: ".csslintrc"
226                        }
227                }
228        }
229});
230
231grunt.registerTask( "default", [ "lint", "test" ] );
232grunt.registerTask( "lint", [ "asciilint", "jshint", "csslint", "htmllint" ] );
233grunt.registerTask( "test", [ "qunit" ] );
234grunt.registerTask( "sizer", [ "concat:ui", "uglify:main", "compare_size:all" ] );
235grunt.registerTask( "sizer_all", [ "concat:ui", "uglify", "compare_size" ] );
236
237// "copy:dist_units_images" is used by unit tests
238grunt.registerTask( "build", [ "concat", "uglify", "cssmin", "copy:dist_units_images" ] );
239
240};
Note: See TracBrowser for help on using the repository browser.