-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathGruntfile.js
94 lines (91 loc) · 2.59 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
84
85
86
87
88
89
90
91
92
93
94
function wrapFile(str) {
var lines = str.split("\n");
return lines.map(function(s) {
return '\'' + s + '\'';
}).join('+\n');
}
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n',
},
build: {
src: 'target/<%= pkg.name %>.js',
dest: 'build/<%= pkg.name %>.min.js'
}
},
copy: {
main: {
nonull: true,
src: 'src/<%= pkg.name %>.js',
dest: 'target/<%= pkg.name %>_raw.js',
options: {
process: function (content, srcpath) {
return grunt.template.process(content);
}
}
},
test: {
nonull: true,
src: 'src/test.html',
dest: 'IGNORED'
},
},
concat: {
dist: {
src: ['target/<%= pkg.name %>_raw.js', 'node_modules/interact.js/dist/interact.js'],
dest: 'target/<%= pkg.name %>.js'
}
},
multidest: {
test: {
tasks: ['copy:test'],
dest: ['target/test.html', 'build/test.html']
}
},
clean: ["target", "build"],
replace: {
minjs: {
src: ['build/test.html'],
overwrite: true,
replacements: [{
from: 'lostpass.js',
to: 'lostpass.min.js'
}]
}
},
watch: {
main: {
files: "src/*",
tasks: "default"
}
},
assets: {
chrome: {
html: wrapFile(grunt.file.read('src/chrome.html', {encoding: 'utf-8'})),
css: wrapFile(grunt.file.read('src/chrome.css', {encoding: 'utf-8'}))
},
firefox: {
html: wrapFile(grunt.file.read('src/firefox.html', {encoding: 'utf-8'})),
css: wrapFile(grunt.file.read('src/firefox.css', {encoding: 'utf-8'}))
},
firefox_login: {
html: {
osx: wrapFile(grunt.file.read('src/firefox_login_osx.html', {encoding: 'utf-8'})),
win: wrapFile(grunt.file.read('src/firefox_login_win.html', {encoding: 'utf-8'})),
},
css: wrapFile(grunt.file.read('src/firefox_login.css', {encoding: 'utf-8'}))
}
}
});
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-multi-dest');
grunt.loadNpmTasks('grunt-text-replace');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.registerTask('default', ['copy:main', 'concat', 'uglify', 'multidest', 'replace']);
};