1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-29 07:16:36 +01:00
metamask-extension/Gruntfile.js

290 lines
6.7 KiB
JavaScript
Raw Normal View History

2015-08-01 03:38:02 +02:00
// Generated on 2015-07-31 using generator-chrome-extension 0.3.1
'use strict';
// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'
module.exports = function (grunt) {
// Load grunt tasks automatically
require('load-grunt-tasks')(grunt);
// Time how long tasks take. Can help when optimizing build times
require('time-grunt')(grunt);
// Configurable paths
var config = {
app: 'app',
dist: 'dist'
};
grunt.initConfig({
// Project settings
config: config,
// Watches files for changes and runs tasks based on the changed files
watch: {
js: {
files: ['<%= config.app %>/scripts/{,*/}*.js'],
options: {
livereload: '<%= connect.options.livereload %>'
2015-08-01 08:05:04 +02:00
},
tasks: ['browserify:dev'],
2015-08-01 03:38:02 +02:00
},
2015-12-22 22:07:30 +01:00
html: {
files: ['<%= config.app %>/{,*/}*.html'],
options: {
livereload: '<%= connect.options.livereload %>'
},
tasks: ['copy'],
},
2015-08-01 03:38:02 +02:00
gruntfile: {
files: ['Gruntfile.js']
},
livereload: {
options: {
livereload: '<%= connect.options.livereload %>'
},
files: [
'<%= config.app %>/*.html',
'<%= config.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
'<%= config.app %>/manifest.json',
'<%= config.app %>/_locales/{,*/}*.json'
]
}
},
2015-08-01 08:05:04 +02:00
// Grunt server and dev server setting
2015-08-01 03:38:02 +02:00
connect: {
options: {
port: 9000,
livereload: 35729,
// change this to '0.0.0.0' to access the server from outside
hostname: 'localhost'
},
2015-08-02 01:33:31 +02:00
dev: {
2015-08-01 03:38:02 +02:00
options: {
open: false,
base: [
2015-08-02 01:33:31 +02:00
'<%= config.dist %>'
2015-08-01 03:38:02 +02:00
]
}
},
test: {
options: {
open: false,
base: [
'test',
'<%= config.app %>'
]
}
}
},
// Empties folders to start fresh
clean: {
2015-08-02 01:33:31 +02:00
basic: {
2015-08-01 03:38:02 +02:00
files: [{
dot: true,
src: [
'<%= config.dist %>/*',
'!<%= config.dist %>/.git*'
]
}]
}
},
// Build js files
browserify: {
2015-08-01 03:38:02 +02:00
dist: {
files: {
'<%= config.dist %>/scripts/background.js': ['<%= config.app %>/scripts/background.js'],
'<%= config.dist %>/scripts/contentscript.js': ['<%= config.app %>/scripts/contentscript.js'],
'<%= config.dist %>/scripts/inpage.js': ['<%= config.app %>/scripts/inpage.js'],
2015-12-22 22:07:30 +01:00
'<%= config.dist %>/scripts/popup.js': ['<%= config.app %>/scripts/popup.js'],
},
},
dev: {
2015-08-01 03:38:02 +02:00
options: {
watch: true,
2015-08-01 03:38:02 +02:00
},
files: {
'<%= config.dist %>/scripts/background.js': ['<%= config.app %>/scripts/background.js'],
'<%= config.dist %>/scripts/contentscript.js': ['<%= config.app %>/scripts/contentscript.js'],
'<%= config.dist %>/scripts/inpage.js': ['<%= config.app %>/scripts/inpage.js'],
2015-12-22 22:07:30 +01:00
'<%= config.dist %>/scripts/popup.js': ['<%= config.app %>/scripts/popup.js'],
},
},
2015-08-01 03:38:02 +02:00
},
// minify js
2015-08-02 01:33:31 +02:00
uglify: {
dist: {
files: {
'<%= config.dist %>/scripts/background.js': [
'<%= config.dist %>/scripts/background.js'
],
'<%= config.dist %>/scripts/contentscript.js': [
'<%= config.dist %>/scripts/contentscript.js'
],
'<%= config.dist %>/scripts/inpage.js': [
'<%= config.dist %>/scripts/inpage.js'
],
}
}
},
2015-08-01 08:05:04 +02:00
2015-08-01 03:38:02 +02:00
// Copies remaining files to places other tasks can use
copy: {
basic: {
2015-08-01 03:38:02 +02:00
files: [{
expand: true,
dot: true,
cwd: '<%= config.app %>',
dest: '<%= config.dist %>',
src: [
'*.{ico,png,txt}',
2016-01-15 03:26:54 +01:00
'images/{,*/}*.*',
2015-08-01 03:38:02 +02:00
'{,*/}*.html',
'styles/{,*/}*.css',
'styles/fonts/{,*/}*.*',
'_locales/{,*/}*.json',
2015-08-02 01:33:31 +02:00
'manifest.json',
2015-08-01 03:38:02 +02:00
]
}]
},
dev: {
files: [{
expand: true,
dot: true,
cwd: '<%= config.app %>',
dest: '<%= config.dist %>',
src: [
'scripts/chromereload.js',
]
}]
},
2015-08-01 03:38:02 +02:00
},
2015-08-01 08:05:04 +02:00
// Auto buildnumber, exclude dev files. smart builds that event pages
2015-08-01 03:38:02 +02:00
chromeManifest: {
dist: {
options: {
buildnumber: true,
indentSize: 2,
background: {
target: 'scripts/background.js',
exclude: [
'scripts/chromereload.js'
]
}
},
2015-08-02 01:33:31 +02:00
src: '<%= config.dist %>',
2015-08-01 03:38:02 +02:00
dest: '<%= config.dist %>'
2015-08-02 01:33:31 +02:00
},
2015-08-01 03:38:02 +02:00
},
// Make sure code styles are up to par and there are no obvious mistakes
jshint: {
options: {
jshintrc: '.jshintrc',
reporter: require('jshint-stylish')
},
all: [
'Gruntfile.js',
'<%= config.app %>/scripts/{,*/}*.js',
'!<%= config.app %>/scripts/vendor/*',
'test/spec/{,*/}*.js'
]
},
// Testing
mocha: {
all: {
options: {
run: true,
urls: ['http://localhost:<%= connect.options.port %>/index.html']
}
}
},
// The following *-min tasks produce minifies files in the dist folder
imagemin: {
dist: {
files: [{
expand: true,
cwd: '<%= config.app %>/images',
src: '{,*/}*.{gif,jpeg,jpg,png}',
dest: '<%= config.dist %>/images'
}]
}
},
2015-08-01 03:38:02 +02:00
// Compres dist files to package
compress: {
dist: {
options: {
archive: function() {
var manifest = grunt.file.readJSON('app/manifest.json');
return 'package/metamask-' + manifest.version + '.zip';
}
},
files: [{
expand: true,
cwd: 'dist/',
src: ['**'],
dest: ''
}]
}
2015-08-02 01:33:31 +02:00
},
// Run some tasks in parallel to speed up build process
concurrent: {
dist: [
'imagemin',
'browserify:dist',
2015-08-02 01:33:31 +02:00
],
},
2015-08-01 03:38:02 +02:00
});
2015-08-01 08:05:04 +02:00
grunt.registerTask('dev', function () {
2015-08-01 03:38:02 +02:00
grunt.task.run([
2015-08-02 01:33:31 +02:00
'clean',
'browserify:dev',
2015-08-02 01:33:31 +02:00
'copy',
'connect:dev',
2015-08-02 01:33:31 +02:00
2015-08-01 08:05:04 +02:00
'watch',
2015-08-01 03:38:02 +02:00
]);
});
grunt.registerTask('test', [
2015-08-02 01:33:31 +02:00
// 'jshint',
'browserify:dist',
2015-08-01 03:38:02 +02:00
'connect:test',
2015-08-02 01:33:31 +02:00
'copy',
'mocha',
2015-08-01 03:38:02 +02:00
]);
grunt.registerTask('build', [
2015-08-02 01:33:31 +02:00
'clean',
2015-08-01 03:38:02 +02:00
'concurrent:dist',
'uglify',
2016-01-15 03:26:54 +01:00
'copy:basic',
2015-08-02 01:33:31 +02:00
'chromeManifest:dist',
'compress',
2015-08-01 03:38:02 +02:00
]);
grunt.registerTask('default', [
'test',
2015-08-02 01:33:31 +02:00
'build',
2015-08-01 03:38:02 +02:00
]);
};