Use Gulp instead of Grunt, minify js files

This commit is contained in:
Raimund Schlüßler 2017-09-02 19:30:37 +02:00
parent 878357ff7c
commit 493dd230c7
No known key found for this signature in database
GPG key ID: 036FA7EB1A599178
11 changed files with 3326 additions and 5456 deletions

View file

@ -38,6 +38,7 @@
"exports": true,
"escapeHTML": true,
"possible": true,
"dav": true
"dav": true,
"OCA": true
}
}

15
js/.stylelintrc Normal file
View file

@ -0,0 +1,15 @@
{
"extends": "stylelint-config-standard",
"plugins": [
"stylelint-scss"
],
"rules": {
"indentation": "tab",
"number-leading-zero": "never",
"comment-empty-line-before": ["always", {
"except": ["first-nested"]
}],
"at-rule-no-unknown": null,
"scss/at-rule-no-unknown": true
}
}

View file

@ -1,130 +0,0 @@
/**
* Nextcloud - Tasks
*
* @author Raimund Schlüßler
* @copyright 2017 Raimund Schlüßler <raimund.schluessler@googlemail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
module.exports = function(grunt) {
'use strict';
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-wrap');
// grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-svg-sprite');
grunt.initConfig({
meta: {
pkg: grunt.file.readJSON('package.json'),
version: '<%= meta.pkg.version %>',
banner: '/**\n' + ' * <%= meta.pkg.description %> - v<%= meta.version %>\n' + ' *\n' + ' * Copyright (c) <%= grunt.template.today("yyyy") %> - ' + '<%= meta.pkg.author.name %> <<%= meta.pkg.author.email %>>\n' + ' *\n' + ' * This file is licensed under the Affero\
General Public License version 3 or later.\n' + ' * See the COPYING file\n' + ' *\n' + ' */\n\n',
build: 'app/',
production: 'public/'
},
concat: {
"default": {
options: {
banner: '<%= meta.banner %>\n',
stripBanners: {
options: 'block'
}
},
src: '<%= meta.build %>/**/*.js',
dest: '<%= meta.production %>app.js'
}
},
wrap: {
"default": {
src: '<%= meta.production %>app.js',
dest: '',
wrapper: ['(function(angular, $, oc_requesttoken, undefined){\n\n', '\n})(window.angular, window.jQuery, oc_requesttoken);']
}
},
jshint: {
files: [
'Gruntfile.js',
'<%= meta.build %>**/*.js'
],
options: {
jshintrc: '.jshintrc',
reporter: require('jshint-stylish')
}
},
watch: {
concat: {
files: [
'<%= meta.build %>**/*.js'
],
options: {
livereload: true
},
tasks: ['js']
}
},
karma: {
unit: {
configFile: 'config/karma.js'
},
continuous: {
configFile: 'config/karma.js',
singleRun: true,
reporters: ['progress', 'junit'],
junitReporter: {
outputFile: 'test-results.xml'
}
}
},
svg_sprite: {
basic: {
// Target basics
expand: true,
cwd: '../img/src',
src: ['**/*.svg'],
dest: '..',
// Target options
options: {
shape: {
transform: []
},
mode: {
css: { // Activate the «css» mode
bust: false,
common: 'icon',
dimensions: '',
prefix: '.ico-%s',
sprite: "../img/sprites.svg",
render: {
css: true // Activate CSS output (with default options)
}
}
}
}
}
}
});
// grunt.registerTask('ci', ['karma:continuous']);
grunt.registerTask('js', ['concat']);
grunt.registerTask('default', 'js');
grunt.registerTask('build', ['concat', 'svg_sprite']);
};

View file

@ -1,20 +0,0 @@
# JS & CSS development
You need grunt installed to compile the coffeescript and less files.
To compile all files run `grunt dev`.
## JS
To compile the coffeescript run:
`grunt js`
## CSS
To compile the less files run:
`grunt css`
## Watch Tasks
Instead of executing the command everytime you change a file, grunt can watch for changes.
Use the following commands instead:
```
grunt watch:dev
grunt watch:js
grunt watch:css
```

159
js/gulpfile.js Normal file
View file

@ -0,0 +1,159 @@
/**
* Nextcloud - Inventory
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Bernhard Posselt <dev@bernhard-posselt.com>
* @copyright Bernhard Posselt 2012, 2014
*
* @author Georg Ehrke
* @copyright 2017 Georg Ehrke <oc.list@georgehrke.com>
*
* @author Raimund Schlüßler
* @copyright 2017 Raimund Schlüßler <raimund.schluessler@googlemail.com>
*/
/*jslint node: true */
'use strict';
// get plugins
const gulp = require('gulp'),
uglify = require('gulp-uglify'),
jshint = require('gulp-jshint'),
KarmaServer = require('karma').Server,
concat = require('gulp-concat'),
wrap = require('gulp-wrap'),
strip = require('gulp-strip-banner'),
babel = require('gulp-babel'),
stylelint = require('gulp-stylelint'),
sourcemaps = require('gulp-sourcemaps'),
svgSprite = require('gulp-svg-sprite'),
npmFiles = require('gulp-npm-files');
// configure
const buildTarget = 'app.min.js';
const scssBuildTarget = 'style.scss';
const karmaConfig = __dirname + '/../tests/js/config/karma.js';
const destinationFolder = __dirname + '/public/';
const scssDestinationFolder = '../css/';
const jsSources = [
'app/**/*.js'
];
const scssSources = [
'../css/src/*.scss'
];
const testSources = ['../tests/js/unit/**/*.js'];
const lintSources = jsSources.concat(testSources).concat(['*.js']);
const watchSources = lintSources;
const svgConfig = {
shape: {
transform: []
},
mode: {
css: { // Activate the «css» mode
bust: false,
common: 'icon',
dimensions: '',
prefix: '.ico-%s',
sprite: "../img/sprites.svg",
render: {
css: {
dest: "../css/sprite.css"
}
}
}
}
};
// tasks
gulp.task('build', ['lint'], () => {
return gulp.src(jsSources)
.pipe(babel({
presets: ['es2015'],
compact: false,
babelrc: false,
ast: false
}))
.pipe(strip())
.pipe(sourcemaps.init({identityMap: true}))
.pipe(concat(buildTarget))
.pipe(wrap(`(function($, oc_requesttoken, undefined){
'use strict';
<%= contents %>
})(jQuery, oc_requesttoken);`))
.pipe(uglify())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest(destinationFolder));
});
// gulp.task('default', ['build', 'vendor', 'scsslint', 'scssConcat']);
gulp.task('default', ['build', 'vendor', 'svg_sprite']);
gulp.task('lint', () => {
return gulp.src(lintSources)
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('default'));
// .pipe(jshint.reporter('fail'));
});
gulp.task('scsslint', () => {
return gulp.src(scssSources)
.pipe(stylelint ({
reporters: [{
formatter: 'string',
console: true
}]
}));
});
gulp.task('scssConcat', ['svg_sprite'], () => {
return gulp.src(scssSources)
.pipe(concat(scssBuildTarget))
.pipe(gulp.dest(scssDestinationFolder));
});
gulp.task('scssConcatWatch', () => {
return gulp.src(scssSources)
.pipe(concat(scssBuildTarget))
.pipe(gulp.dest(scssDestinationFolder));
});
gulp.task('watch', () => {
gulp.watch(watchSources, ['build']);
gulp.watch(scssSources, ['scssConcatWatch']);
});
gulp.task('karma', (done) => {
new KarmaServer({
configFile: karmaConfig,
singleRun: true,
browsers: ['Firefox'],
reporters: ['progress', 'coverage']
}, done).start();
});
gulp.task('watch-karma', (done) => {
new KarmaServer({
configFile: karmaConfig,
autoWatch: true,
browsers: ['Firefox'],
reporters: ['progress', 'coverage']
}, done).start();
});
gulp.task('svg_sprite', () => {
return gulp.src('**/*.svg', {cwd: '../img/src'})
.pipe(svgSprite(svgConfig))
.pipe(gulp.dest('..'));
});
gulp.task("vendor", () => {
return gulp.src(npmFiles(), { base: "./node_modules" })
.pipe(gulp.dest('vendor'));
});

View file

@ -6,12 +6,13 @@
"name": "Raimund Schlüßler",
"email": "raimund.schluessler@googlemail.com"
},
"license": "AGPLv3",
"private": true,
"homepage": "",
"homepage": "https://github.com/nextcloud/tasks",
"scripts": {
"test": "node node_modules/grunt-cli/bin/grunt karma",
"test": "node node_modules/gulp-cli/bin/gulp.js karma",
"prebuild": "yarn install && yarn upgrade && node_modules/bower/bin/bower install && node_modules/bower/bin/bower update",
"build": "node node_modules/grunt-cli/bin/grunt build"
"build": "node node_modules/gulp-cli/bin/gulp.js"
},
"repository": {
"type": "git",
@ -21,17 +22,26 @@
"contributors": [],
"dependencies": {},
"devDependencies": {
"babel-preset-es2015": "^6.14.0",
"bower": "*",
"grunt": "^1.0.1",
"grunt-cli": "^1.2.0",
"grunt-concurrent": "^2.3.1",
"grunt-contrib-concat": "^1.0.1",
"grunt-contrib-jshint": "^1.0.0",
"grunt-contrib-watch": "^1.0.0",
"grunt-karma": "^2.0.0",
"grunt-svg-sprite": "1.3.7",
"grunt-wrap": "^0.3.0",
"jshint-stylish": "^2.2.1"
"gulp": "^3.9.1",
"gulp-babel": "^6.1.2",
"gulp-cli": "^1.2.2",
"gulp-concat": "^2.6.1",
"gulp-jshint": "^2.0.4",
"gulp-ng-annotate": "^2.0.0",
"gulp-npm-files": "^0.1.3",
"gulp-sourcemaps": "^2.4.0",
"gulp-strip-banner": "0.0.2",
"gulp-stylelint": "^4.0.0",
"gulp-svg-sprite": "1.3.7",
"gulp-uglify": "^2.0.0",
"gulp-wrap": "^0.13.0",
"jshint": "^2.9.4",
"karma": "^1.3.0",
"stylelint": "^8.0.0",
"stylelint-config-standard": "^17.0.0",
"stylelint-scss": "^2.1.0"
},
"engines": {
"node": ">=6"

File diff suppressed because it is too large Load diff

4
js/public/app.min.js vendored Normal file

File diff suppressed because one or more lines are too long

1
js/public/app.min.js.map Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

View file

@ -6,7 +6,7 @@
script('tasks', 'vendor/angular-draganddrop/angular-drag-and-drop-lists.min');
script('tasks', 'vendor/angular-ui-select/dist/select.min');
script('tasks', 'vendor/jstzdetect/jstz.min');
script('tasks', 'public/app');
script('tasks', 'public/app.min');
script('tasks', 'vendor/jquery-timepicker/jquery.ui.timepicker');
script('tasks', 'vendor/ical.js/build/ical');
style('tasks', 'style');