mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-06 08:25:19 +01:00
set grunt scripts for releasing
This commit is contained in:
parent
ccfa09f6c1
commit
bc6e8a8ffc
3 changed files with 67 additions and 35 deletions
64
Gruntfile.js
Normal file
64
Gruntfile.js
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
'use strict'
|
||||||
|
const webpack = require('webpack');
|
||||||
|
const webpackConfig = require('./webpack.config');
|
||||||
|
const del = require('del');
|
||||||
|
const exec = require('child_process').exec;
|
||||||
|
|
||||||
|
module.exports = function(grunt) {
|
||||||
|
grunt.loadNpmTasks('grunt-contrib-copy');
|
||||||
|
|
||||||
|
function dirFilter(dirsToFilter) {
|
||||||
|
return (path) => {
|
||||||
|
for (let dir of dirsToFilter) {
|
||||||
|
if (path.startsWith(dir + '/') || path == dir) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
grunt.initConfig({
|
||||||
|
copy: {
|
||||||
|
resources: {
|
||||||
|
expand: true,
|
||||||
|
cwd: 'web',
|
||||||
|
src: '**',
|
||||||
|
dest: 'dist/',
|
||||||
|
filter: dirFilter(['web/app', 'web/test'])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
grunt.registerTask('clean', function() {
|
||||||
|
del.sync('dist');
|
||||||
|
});
|
||||||
|
|
||||||
|
grunt.registerTask('build', function() {
|
||||||
|
const done = this.async();
|
||||||
|
webpack(webpackConfig, function (error) {
|
||||||
|
if (error) {
|
||||||
|
console.log('webpack failed');
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
grunt.registerTask('show-revision', function() {
|
||||||
|
const done = this.async();
|
||||||
|
exec('git rev-parse --short HEAD', (err, stdout, stderr) => {
|
||||||
|
grunt.log.writeln(stdout);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
grunt.registerTask('mark-revision', function() {
|
||||||
|
const done = this.async();
|
||||||
|
exec('mkdir -p dist && git rev-parse HEAD > dist/.rev', function (err, stdout, stderr) {
|
||||||
|
done(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
grunt.registerTask('default', ['clean', 'build', 'copy:resources', 'mark-revision', 'show-revision']);
|
||||||
|
};
|
||||||
32
gulpfile.js
32
gulpfile.js
|
|
@ -1,32 +0,0 @@
|
||||||
const gulp = require('gulp');
|
|
||||||
const webpack = require('webpack');
|
|
||||||
const webpackConfig = require('./webpack.config');
|
|
||||||
const del = require('del');
|
|
||||||
|
|
||||||
gulp.task('clean', function () {
|
|
||||||
del('dist')
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('build', function () {
|
|
||||||
webpack(webpackConfig, function (error) {
|
|
||||||
if (error) {
|
|
||||||
console.log('webpack failed');
|
|
||||||
console.log(error);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('resources', function () {
|
|
||||||
const res = [];
|
|
||||||
excluding('web/app', res);
|
|
||||||
excluding('web/test', res);
|
|
||||||
res.push('web/**/*');
|
|
||||||
gulp.src(res).pipe(gulp.dest('dist'));
|
|
||||||
});
|
|
||||||
|
|
||||||
function excluding(path, filter) {
|
|
||||||
filter.push('!' + path + '/**/*', '!' + path);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
gulp.task('default', ['clean', 'build', 'resources']);
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "webpack-dev-server --content-base web/ --port 3000",
|
"start": "webpack-dev-server --content-base web/ --port 3000",
|
||||||
"pack": "webpack --config webpack.config.js --progress --profile --colors",
|
"pack": "webpack --config webpack.config.js --progress --profile --colors",
|
||||||
"build": "gulp",
|
"build": "grunt",
|
||||||
"lint": "eslint web/app -c ./build/.eslintrc.json --ignore-path ./build/.eslintignore"
|
"lint": "eslint web/app -c ./build/.eslintrc.json --ignore-path ./build/.eslintignore"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
@ -37,8 +37,8 @@
|
||||||
"style-loader": "0.13.1",
|
"style-loader": "0.13.1",
|
||||||
"webpack": "1.13.2",
|
"webpack": "1.13.2",
|
||||||
"webpack-dev-server": "1.15.0",
|
"webpack-dev-server": "1.15.0",
|
||||||
"gulp": "3.9.1",
|
"grunt": "1.0.1",
|
||||||
"del": "2.2.2"
|
"grunt-contrib-copy": "1.0.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"sprintf": "0.1.5",
|
"sprintf": "0.1.5",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue