Subversion-Projekte lars-tiefland.zeldi.de

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
2 lars 1
'use strict';
2
 
3
var browsers = [
4
    'last 2 versions',
5
    'ie 9',
6
    'ie 10',
7
    'Firefox ESR',
8
    'Opera 12.1'
9
];
10
 
11
module.exports = function(grunt) {
12
    grunt.initConfig({
13
        pkg: grunt.file.readJSON('package.json'),
14
 
15
        meta: {
16
            banner: '\n/*!\n * <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
17
                '<%= grunt.template.today("dd.mm.yyyy") %>\n' +
18
                ' * <%= pkg.homepage %>\n' +
19
                ' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>, <%= _.pluck(pkg.contributors, "name").join(", ") %>\n' +
20
                ' * Licensed under the <%= pkg.license %> license\n */\n\n'
21
        },
22
 
23
        browserify: {
24
            options: {
25
                browserifyOptions: {
26
                    fullPaths: false
27
                },
28
                banner: '<%= meta.banner %>'
29
            },
30
            dev_demo: {
31
                options: {
32
                    browserifyOptions: {
33
                        debug: true
34
                    },
35
                    keepAlive: true,
36
                    watch: true
37
                },
38
                src: 'src/js/shariff.js',
39
                dest: 'demo/app.min.js'
40
            },
41
            dist_complete_min: {
42
                options: {
43
                    transform: [ ['uglifyify', { global: true } ] ]
44
                },
45
                src: 'src/js/shariff.js',
46
                dest: 'build/shariff.complete.js'
47
            },
48
            dist_min: {
49
                options: {
50
                    transform: [
51
                        ['uglifyify', { global: true } ],
52
                        ['browserify-shim', { global: true } ]
53
                    ]
54
                },
55
                src: 'src/js/shariff.js',
56
                dest: 'build/shariff.min.js'
57
            },
58
            demo: {
59
                options: {
60
                    transform: [ ['uglifyify', { global: true } ] ],
61
                    watch: true
62
                },
63
                src: 'src/js/shariff.js',
64
                dest: 'demo/app.min.js'
65
            }
66
        },
67
 
68
        copy: {
69
            demo: {
70
                files: [
71
                    {
72
                        expand: true,
73
                        cwd: 'node_modules/font-awesome',
74
                        src: '{fonts,css}/*',
75
                        dest: 'demo/'
76
                    },
77
                    {
78
                        src: 'build/*',
79
                        dest: 'demo/'
80
                    }
81
                ]
82
            }
83
        },
84
 
85
        jshint: {
86
            options: {
87
                jshintrc: '.jshintrc'
88
            },
89
            files: [
90
                'src/js/*.js',
91
                'src/js/services/*.js'
92
            ]
93
        },
94
 
95
        less: {
96
            options: {
97
                banner: '<%= meta.banner %>',
98
                paths: [
99
                    'node_modules/font-awesome/less',
100
                    'node_modules/shariff/src/style'
101
                ],
102
                plugins: [
103
                    new (require('less-plugin-autoprefix'))({browsers: browsers}),
104
                    new (require('less-plugin-clean-css'))({keepSpecialComments: 1})
105
                ],
106
                strictMath: true
107
            },
108
            demo: {
109
                options: {
110
                    sourceMap: true,
111
                    outputSourceFiles: true,
112
                    sourceMapFileInline: true,
113
                    plugins: [
114
                        new (require('less-plugin-autoprefix'))({
115
                            browsers: browsers,
116
                            map: true
117
                        }),
118
                        new (require('less-plugin-clean-css'))()
119
                    ],
120
                },
121
                src: 'src/style/demo.less',
122
                dest: 'demo/app.min.css'
123
            },
124
            dist: {
125
                options: {
126
                    modifyVars: {
127
                        'fa-font-path': '"https://netdna.bootstrapcdn.com/font-awesome/4.3.0/fonts"'
128
                    }
129
                },
130
                src: 'src/style/shariff-complete.less',
131
                dest: 'build/shariff.complete.css'
132
            },
133
            dist_min: {
134
                src: 'src/style/shariff.less',
135
                dest: 'build/shariff.min.css'
136
            }
137
        },
138
 
139
        hapi: {
140
            shariff: {
141
                options: {
142
                    server: require('path').resolve('./node_modules/shariff-backend-node/server.js'),
143
                    // noasync: true,
144
                }
145
            }
146
        },
147
 
148
        connect: {
149
            demo: {
150
                options: {
151
                    hostname: '0.0.0.0',
152
                    // hostname: 'localhost',
153
                    port: 8080,
154
                    base: 'demo',
155
                    keepalive: true,
156
                    // livereload: true,
157
                    // open: true,
158
                    // debug: true,
159
                    middleware: function (connect, options, middlewares) {
160
                        var proxy = require('grunt-connect-proxy/lib/utils').proxyRequest;
161
                        return [
162
                            proxy,
163
                            connect.static(options.base[0]),
164
                            connect.directory(options.base[0])
165
                        ];
166
                    }
167
                },
168
                proxies: [
169
                    {
170
                        rewrite: {
171
                            '^/shariff': ''
172
                        },
173
                        context: '/shariff/',
174
                        host: 'localhost',
175
                        port: 3001,
176
                        https: false,
177
                        xforward: false
178
                    }
179
                ]
180
            }
181
        }
182
    });
183
 
184
    grunt.loadNpmTasks('grunt-browserify');
185
    grunt.loadNpmTasks('grunt-contrib-copy');
186
    grunt.loadNpmTasks('grunt-contrib-jshint');
187
    grunt.loadNpmTasks('grunt-contrib-less');
188
    grunt.loadNpmTasks('grunt-contrib-connect');
189
    grunt.loadNpmTasks('grunt-connect-proxy');
190
    grunt.loadNpmTasks('grunt-hapi');
191
 
192
    grunt.registerTask('test', ['jshint']);
193
    grunt.registerTask('build', ['test', 'less:demo', 'less:dist', 'less:dist_min', 'browserify:dist_complete_min', 'browserify:dist_min']);
194
    grunt.registerTask('demo', ['copy:demo', 'less:demo', 'browserify:demo', 'hapi', 'configureProxies:demo', 'connect']);
195
    grunt.registerTask('default', ['test', 'demo']);
196
};