-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.js
83 lines (70 loc) · 2.12 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
var fs = require('fs');
var pickFiles = require('broccoli-static-compiler');
var compileSass = require('broccoli-sass');
var mergeTrees = require('broccoli-merge-trees');
var imagemin = require('broccoli-imagemin');
var JPEGRecompress = require('imagemin-jpeg-recompress');
var PNGCrush = require('imagemin-pngcrush');
var SVGO = require('imagemin-svgo');
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
broccoli: {
default: {
dest: 'dist',
config: function () {
var mainCSS = 'build/css';
mainCSS = pickFiles(mainCSS, {
srcDir: '/',
files: ['**/*.scss'],
destDir: '/css'
});
mainCSS = compileSass(['build/css'], 'main.scss', 'css/main.css', {outputStyle: 'expanded'});
var js = 'build/js';
js = pickFiles(js, {
srcDir: '/',
destDir: '/js'
});
var lib = 'build/lib';
lib = pickFiles(lib, {
srcDir: '/',
destDir: '/lib'
});
var img = 'build/images';
img = pickFiles(img, {
srcDir: '/',
destDir: '/images'
});
img = imagemin(img, {
interlaced: true,
optimizationLevel: 3,
progressive: true,
});
var html = 'build/html';
html = pickFiles(html, {
srcDir: '/',
destDir: '/templates'
});
var pkgFiles = 'build/';
pkgFiles = pickFiles(pkgFiles, {
srcDir: '/',
files: ['manifest.json'],
destDir: '/'
});
return mergeTrees([mainCSS, js, img, html, lib, pkgFiles]);
}
}
}
});
grunt.loadNpmTasks('grunt-broccoli');
grunt.registerTask('default', ['broccoli:default:build']);
grunt.registerTask('watch', ['broccoli:default:watch']);
grunt.registerTask('pkg', 'Package for the chrome webstore', packageExtension);
};
function packageExtension() {
// remove the data-env flag from the body so our unit tests, etc. don't run
var file = fs.readFileSync('./dist/templates/newtab.html', {encoding: 'utf8'});
console.log(file);
file = file.replace('data-env="dev"', 'data-env="prod"');
fs.writeFileSync('./dist/templates/newtab.html', file);
}