Optimize gulp
This commit is contained in:
parent
a37579c06a
commit
ec4566e023
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,3 +3,4 @@ test.html
|
||||
node_modules/
|
||||
dist/ffnm.min.js.map
|
||||
package-lock.json
|
||||
dist/.DS_Store
|
||||
|
@ -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
2
dist/ffnm.min.js
vendored
File diff suppressed because one or more lines are too long
@ -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
1370
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -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"
|
||||
}
|
||||
}
|
||||
|
27
src/core.js
27
src/core.js
@ -1,3 +1,4 @@
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
|
||||
//===
|
||||
// VARIABLES
|
||||
@ -6,14 +7,17 @@ const EVENTS = ['i-click', 'i-view', 'i-scroll-up', 'i-scroll-down', 'i-hover'];
|
||||
const FUNCTION_TREE = {
|
||||
'class': ['add', 'remove', 'toggle']
|
||||
};
|
||||
let elementsValidates = [];
|
||||
|
||||
//===
|
||||
// FUNCTIONS
|
||||
//===
|
||||
/**
|
||||
* Method that validates syntax and reports.
|
||||
* return - Bool
|
||||
*/
|
||||
function validateSyntax() {
|
||||
|
||||
// Get every items from EVENTS
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
//===
|
||||
// LINTER
|
||||
//===
|
||||
function addEventClick() {
|
||||
}
|
||||
|
||||
|
||||
//===
|
||||
// INIT
|
||||
//===
|
||||
console.log("EStabien " + validateSyntax());
|
||||
validateSyntax();
|
||||
|
||||
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user