Update README.md
[inboxen.git] / Gruntfile.js
blob504b62932ff0015c81c48685e11db595ace2cd9c
1 module.exports = function(grunt) {
2     var sass = require('sass');
4     var preprocessors = {};
5     if (!process.env.SKIP_COVERAGE) {
6         preprocessors["<%= dirs.js %>/src/*.js"] = ["coverage"];
7     }
9     grunt.initConfig({
10         pkg: grunt.file.readJSON("package.json"),
11         dirs: {
12             build: "frontend/build",
13             css: "frontend/css",
14             js: "frontend/js",
15             static: "inboxen/static/compiled",
16             thirdparty: "node_modules",
17         },
18         clean: {
19             build: ["<%= dirs.build %>", "<%= dirs.static %>"],
20         },
21         copy: {
22             fonts: {
23                 expand: true,
24                 nonull: true,
25                 flatten: true,
26                 src: "<%= dirs.thirdparty %>/font-awesome/fonts/*",
27                 dest: "<%= dirs.static %>/fonts/",
28             }
29         },
30         concat: {
31             options: {
32                 sourceMap: true,
33             },
34             website: {
35                 src: [
36                     "<%= dirs.thirdparty %>/jquery/dist/jquery.js",
37                     "<%= dirs.js %>/src/utils.js",
38                     "<%= dirs.js %>/src/copy.js",
39                     "<%= dirs.js %>/src/alert.js",
40                     "<%= dirs.js %>/src/home.js",
41                     "<%= dirs.js %>/src/search.js",
42                     "<%= dirs.js %>/src/inbox.js",
43                 ],
44                 dest: "<%= dirs.build %>/src/website.js",
45                 nonnull: true
46             },
47             stats: {
48                 src: [
49                     "<%= dirs.thirdparty %>/patternomaly/dist/patternomaly.js",
50                     "<%= dirs.thirdparty %>/chart.js/dist/Chart.js",
51                     "<%= dirs.js %>/src/stats.js",
52                 ],
53                 dest: "<%= dirs.build %>/src/stats.js",
54                 nonnull: true
55             }
56         },
57         uglify: {
58             options: {
59                 mangle: true,
60                 compress: true,
61                 sourceMap: {
62                     includeSources: true
63                 },
64                 output: {
65                     comments: /^!/
66                 }
67             },
68             website: {
69                 src: ["<%= dirs.build %>/src/website.js"],
70                 dest: "<%= dirs.static %>/website.min.js"
71             },
72             stats: {
73                 src: ["<%= dirs.build %>/src/stats.js"],
74                 dest: "<%= dirs.static %>/stats.min.js"
75             }
76         },
77         sass: {
78             options: {
79                 implementation: sass,
80                 outputStyle: "compressed",
81                 includePaths: ["<%= dirs.thirdparty %>"],
82                 sourceMap: true,
83                 sourceMapContents: true,
84                 sourceMapEmbed: false
85             },
86             publicCss: {
87                 src: ["<%= dirs.css %>/inboxen.scss"],
88                 dest: "<%= dirs.static %>/website.css"
89             }
90         },
91         karma: {
92             options: {
93                 client: {
94                     jasmine: {
95                         random: true,
96                         stopSpecOnExpectationFailure: false
97                     }
98                 },
99                 configFile: "karma.conf.js",
100                 preprocessors: preprocessors,
101                 files: [
102                     {
103                         pattern: "<%= dirs.js %>/data/*.html",
104                         type: "dom"
105                     },
106                     {
107                         pattern: "<%= dirs.js %>/data/*.json",
108                         included: false,
109                         served: true,
110                     },
111                     "<%= dirs.thirdparty %>/jquery/dist/jquery.js",
112                     "<%= dirs.thirdparty %>/chart.js/dist/Chart.js",
113                     "<%= dirs.js %>/src/*.js",
114                     "<%= dirs.js %>/tests/*.js"
115                 ]
116             },
117             chromium: {
118                 singleRun: true,
119                 browsers: ["ChromiumMaybeHeadless"]
120             },
121             firefox: {
122                 singleRun: true,
123                 browsers: ["Firefox"]
124             },
125             chromiumDebug: {
126                 singleRun: false,
127                 browsers: ["ChromiumMaybeHeadless"]
128             },
129             firefoxDebug: {
130                 singleRun: false,
131                 browsers: ["Firefox"]
132             },
133             debug: {
134                 singleRun: false,
135                 browsers: []
136             }
137         },
138         jshint: {
139             options: {jshintrc: true},
140             all: ["<%= dirs.js %>"]
141         }
142     });
144     grunt.loadNpmTasks('grunt-contrib-clean');
145     grunt.loadNpmTasks('grunt-contrib-copy');
146     grunt.loadNpmTasks("grunt-contrib-concat");
147     grunt.loadNpmTasks("grunt-contrib-uglify");
148     grunt.loadNpmTasks('grunt-sass');
149     grunt.loadNpmTasks('grunt-karma');
150     grunt.loadNpmTasks('grunt-contrib-jshint');
152     grunt.registerTask("default", ["clean", "copy", "concat", "uglify", "sass"]);
153     grunt.registerTask("tests", ["karma:firefox", "karma:chrome"]);