Optimize gulp

This commit is contained in:
Andros Fenollosa 2020-07-04 16:57:28 +02:00
parent a37579c06a
commit ec4566e023
7 changed files with 118 additions and 1357 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@ test.html
node_modules/
dist/ffnm.min.js.map
package-lock.json
dist/.DS_Store

View File

@ -16,7 +16,7 @@ Simple plugin to avoid writing Javascript in trivial tasks.
Añade a tu `<head>` la siguiente etiqueta.
```html
<script defer src="https://cdn.jsdelivr.net/gh/tanrax/FFNM@v1.0.0/ffnm.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/tanrax/FFNM@v1.0.0/ffnm.min.js"></script>
```
### Ejemplos de uso

2
dist/ffnm.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -2,9 +2,8 @@
// IMPORTS
//===
const { series, parallel, src, dest, watch } = require('gulp');
const babel = require('gulp-babel');
const sourcemaps = require('gulp-sourcemaps');
const uglify = require('gulp-uglify');
const uglify = require('gulp-uglify-es').default;
const concat = require('gulp-concat');
//===
@ -23,9 +22,6 @@ function js(cb) {
return src([SRC_PATH + 'core.js'])
.pipe(sourcemaps.init())
.pipe(concat(DIST_JS))
.pipe(babel({
presets: ['@babel/env']
}))
.pipe(uglify())
.pipe(sourcemaps.write('.'))
.pipe(dest(DIST_PATH));

1370
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -22,5 +22,8 @@
"bugs": {
"url": "https://github.com/tanrax/FFNM/issues"
},
"homepage": "https://github.com/tanrax/FFNM#readme"
"homepage": "https://github.com/tanrax/FFNM#readme",
"devDependencies": {
"gulp-uglify-es": "^2.0.0"
}
}

View File

@ -1,19 +1,23 @@
document.addEventListener('DOMContentLoaded', () => {
//===
// VARIABLES
//===
const EVENTS = ['i-click', 'i-view', 'i-scroll-up', 'i-scroll-down', 'i-hover'];
const FUNCTION_TREE = {
//===
// VARIABLES
//===
const EVENTS = ['i-click', 'i-view', 'i-scroll-up', 'i-scroll-down', 'i-hover'];
const FUNCTION_TREE = {
'class': ['add', 'remove', 'toggle']
};
//===
// FUNCTIONS
//===
function validateSyntax() {
// Get every items from EVENTS
};
let elementsValidates = [];
//===
// FUNCTIONS
//===
/**
* Method that validates syntax and reports.
* return - Bool
*/
function validateSyntax() {
elementsValidates = [];
// Check all event syntax
return EVENTS.map((event) => {
// Check element FUNCTION_TREE
@ -25,24 +29,27 @@ function validateSyntax() {
return RegExp(`^${key}:${method}\\('\\w+', *'[#,.,a-zA-Z]\\w*'\\)$`).test(element.getAttribute(event));
}).some(method => method);
}).every(key => key);
if(checked) {
// Save element validate
elementsValidates.push(element);
} else {
// Notify error
if(!checked) {
console.error('FFNM: Bad syntax');
console.error(element);
}
return checked;
}).every(item => item);
}).every(event => event);
}
}
function addEventClick() {
}
//===
// LINTER
//===
//===
// INIT
//===
validateSyntax();
//===
// INIT
//===
console.log("EStabien " + validateSyntax());
});