mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
The command "grunt" now builds everything.
Switched webpack build over to grunt.
This commit is contained in:
20
grunt.js
20
grunt.js
@@ -1,4 +1,6 @@
|
||||
module.exports = function(grunt) {
|
||||
grunt.loadNpmTasks('grunt-webpack');
|
||||
|
||||
grunt.initConfig({
|
||||
pkg: '<json:package.json',
|
||||
meta: {
|
||||
@@ -34,8 +36,24 @@ module.exports = function(grunt) {
|
||||
dest: 'build/sjcl.js'
|
||||
}
|
||||
},
|
||||
webpack: {
|
||||
lib: {
|
||||
src: "src/js/index.js",
|
||||
dest: "build/ripple-<%= pkg.version %>.js"
|
||||
},
|
||||
lib_debug: {
|
||||
src: "src/js/index.js",
|
||||
dest: "build/ripple-<%= pkg.version %>.js",
|
||||
debug: true
|
||||
},
|
||||
lib_min: {
|
||||
src: "src/js/index.js",
|
||||
dest: "build/ripple-<%= pkg.version %>.js",
|
||||
minimize: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Tasks
|
||||
grunt.registerTask('default', 'concat:sjcl');
|
||||
grunt.registerTask('default', 'concat:sjcl webpack');
|
||||
};
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"buster": "~0.6.2",
|
||||
"webpack": "~0.7.17"
|
||||
"grunt-webpack": "~0.4.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "buster test"
|
||||
|
||||
68
webpack.js
68
webpack.js
@@ -1,68 +0,0 @@
|
||||
var pkg = require('./package.json');
|
||||
var webpack = require("webpack");
|
||||
var async = require("async");
|
||||
var extend = require("extend");
|
||||
|
||||
var cfg = {
|
||||
// General settings
|
||||
baseName: pkg.name,
|
||||
programPath: __dirname + "/src/js/index.js",
|
||||
|
||||
// CLI-configurable options
|
||||
watch: false,
|
||||
outputDir: __dirname + "/build"
|
||||
};
|
||||
for (var i = 0, l = process.argv.length; i < l; i++) {
|
||||
var arg = process.argv[i];
|
||||
if (arg === '-w' || arg === '--watch') {
|
||||
cfg.watch = true;
|
||||
} else if (arg === '-o') {
|
||||
cfg.outputDir = process.argv[++i];
|
||||
}
|
||||
};
|
||||
|
||||
var builds = [{
|
||||
filename: 'ripple-'+pkg.version+'.js',
|
||||
},{
|
||||
filename: 'ripple-'+pkg.version+'-debug.js',
|
||||
debug: true
|
||||
},{
|
||||
filename: 'ripple-'+pkg.version+'-min.js',
|
||||
minimize: true
|
||||
}];
|
||||
|
||||
var defaultOpts = {
|
||||
// [sic] Yes, this is the spelling upstream.
|
||||
libary: 'ripple',
|
||||
// However, it's fixed in webpack 0.8, so we include the correct spelling too:
|
||||
library: 'ripple',
|
||||
watch: cfg.watch
|
||||
};
|
||||
|
||||
function build(opts) {
|
||||
var opts = extend({}, defaultOpts, opts);
|
||||
opts.output = cfg.outputDir + "/"+opts.filename;
|
||||
return function (callback) {
|
||||
var filename = opts.filename;
|
||||
webpack(cfg.programPath, opts, function (err, result) {
|
||||
console.log(' '+filename, result.hash, '['+result.modulesCount+']');
|
||||
if ("function" === typeof callback) {
|
||||
callback(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (!cfg.watch) {
|
||||
console.log('Compiling Ripple JavaScript...');
|
||||
async.series(builds.map(build), function (err) {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
console.log('Watching files for changes...');
|
||||
builds.map(build).forEach(function (build) {
|
||||
build();
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user