Develop #3
51
gulpfile.js
51
gulpfile.js
@ -1,28 +1,57 @@
|
|||||||
const { src, dest, watch } = require('gulp');
|
const { src, dest, watch, parallel } = require('gulp');
|
||||||
const sass = require('gulp-sass')(require('sass'));
|
const sass = require('gulp-sass')(require('sass'));
|
||||||
const browserify = require('browserify');
|
const browserify = require('browserify');
|
||||||
const Babelify = require('babelify');
|
const Babelify = require('babelify');
|
||||||
const source = require('vinyl-source-stream');
|
const source = require('vinyl-source-stream');
|
||||||
const buffer = require('vinyl-buffer');
|
const buffer = require('vinyl-buffer');
|
||||||
const uglify = require('gulp-uglify');
|
const uglify = require('gulp-uglify');
|
||||||
|
const connect = require('gulp-connect');
|
||||||
|
|
||||||
|
const paths = {
|
||||||
|
html: {
|
||||||
|
all: 'src/templates/**/*.html'
|
||||||
|
},
|
||||||
|
|
||||||
|
styles: {
|
||||||
|
all: 'src/styles/**/*.scss',
|
||||||
|
main: 'src/styles/main.scss',
|
||||||
|
},
|
||||||
|
|
||||||
|
scripts: {
|
||||||
|
all: 'src/scripts/**/*.js',
|
||||||
|
main: 'src/scripts/app.js',
|
||||||
|
},
|
||||||
|
|
||||||
|
output: 'dist',
|
||||||
|
};
|
||||||
|
|
||||||
|
function html () {
|
||||||
|
return src(paths.html.all,).pipe(dest(paths.output));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function styles() {
|
function styles() {
|
||||||
return src('src/styles/main.scss').pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError)).pipe(dest('dist'));
|
return src(paths.styles.main).pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError)).pipe(dest(paths.output));
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
function scripts () {
|
function server () {
|
||||||
return browserify('src/scripts/app.js').transform(Babelify.configure({presets: ['@babel/preset-env'],})).bundle().pipe(source('bundle.js')).pipe(buffer()).pipe(uglify()).pipe(dest('dist'));
|
connect.server({
|
||||||
}
|
root: paths.output,
|
||||||
|
livereload: true,
|
||||||
|
port: 3000,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function sentinel () {
|
||||||
|
watch(paths.html.all, {ignoreInitial: false}, html);
|
||||||
|
watch(paths.styles.all, {ignoreInitial: false}, styles);
|
||||||
|
watch(paths.scripts.all, {ignoreInitial: false}, scripts);
|
||||||
|
}
|
||||||
|
|
||||||
function sentinel () {
|
function scripts () {
|
||||||
watch('src/styles/**/*.scss', {ignoreInitial: false}, styles);
|
return browserify(paths.scripts.main).transform(Babelify.configure({presets: ['@babel/preset-env'],})).bundle().pipe(source('bundle.js')).pipe(buffer()).pipe(uglify()).pipe(dest(paths.output));
|
||||||
watch('src/scripts/**/*.js', {ignoreInitial: false}, scripts);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
exports.default = parallel (server, sentinel);
|
||||||
exports.sentinel = sentinel;
|
|
||||||
|
1146
package-lock.json
generated
1146
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -5,7 +5,7 @@
|
|||||||
"main": "js.js",
|
"main": "js.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
"dev": "gulp sentinel"
|
"dev": "gulp"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -19,6 +19,7 @@
|
|||||||
"babelify": "^10.0.0",
|
"babelify": "^10.0.0",
|
||||||
"browserify": "^17.0.0",
|
"browserify": "^17.0.0",
|
||||||
"gulp": "^4.0.2",
|
"gulp": "^4.0.2",
|
||||||
|
"gulp-connect": "^5.7.0",
|
||||||
"gulp-sass": "^5.1.0",
|
"gulp-sass": "^5.1.0",
|
||||||
"gulp-uglify": "^3.0.2",
|
"gulp-uglify": "^3.0.2",
|
||||||
"sass": "^1.56.1",
|
"sass": "^1.56.1",
|
||||||
|
@ -17,21 +17,28 @@ export class TouristAttractions {
|
|||||||
|
|
||||||
this.inputTitle = document.querySelector('.input-text__titulo');
|
this.inputTitle = document.querySelector('.input-text__titulo');
|
||||||
this.inputDescription = document.querySelector('.input-text__descricao');
|
this.inputDescription = document.querySelector('.input-text__descricao');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
events () {
|
events () {
|
||||||
this.inputFile.addEventListener('change', this.imgPreview.bind(this));
|
this.inputFile.addEventListener('change', this.imgPreview.bind(this), false);
|
||||||
this.form.addEventListener('submit', this.addProperty.bind(this));
|
this.form.addEventListener('submit', this.addProperty.bind(this));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
imgPreview (e) {
|
imgPreview (e) {
|
||||||
const inputTarget = e.target;
|
const inputTarget = e.target;
|
||||||
const file = inputTarget.files[0];
|
const file = inputTarget.files[0];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (file) {
|
if (file) {
|
||||||
|
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
reader.addEventListener('load', (e) => {
|
reader.addEventListener('load', (e) => {
|
||||||
const readerTarget = e.target;
|
const readerTarget = e.target;
|
||||||
|
|
||||||
@ -39,13 +46,17 @@ export class TouristAttractions {
|
|||||||
img.src = readerTarget.result;
|
img.src = readerTarget.result;
|
||||||
img.classList.add('img-result');
|
img.classList.add('img-result');
|
||||||
|
|
||||||
|
|
||||||
|
this.labelInput.innerText = "";
|
||||||
|
|
||||||
|
|
||||||
this.labelInput.appendChild(img);
|
this.labelInput.appendChild(img);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
reader.readAsDataURL(file);
|
reader.readAsDataURL(file);
|
||||||
|
|
||||||
this.labelInput.innerText = "";
|
|
||||||
this.labelInput.style.border = "none";
|
this.labelInput.style.border = "none";
|
||||||
|
|
||||||
|
|
||||||
@ -65,7 +76,7 @@ export class TouristAttractions {
|
|||||||
const spotDescription = e.target['input-description'].value
|
const spotDescription = e.target['input-description'].value
|
||||||
|
|
||||||
|
|
||||||
if (spotImg != '' && spotTitle != '' && spotDescription != '') {
|
if (this.spotImg != '' && spotTitle != '' && spotDescription != '') {
|
||||||
|
|
||||||
const spot = {
|
const spot = {
|
||||||
image: spotImg.src,
|
image: spotImg.src,
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<link rel="stylesheet" href="../dist/main.css">
|
<link rel="stylesheet" href="main.css">
|
||||||
|
|
||||||
<title>Tourist Attractions</title>
|
<title>Tourist Attractions</title>
|
||||||
</head>
|
</head>
|
||||||
@ -55,7 +55,7 @@
|
|||||||
|
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<script src="../dist/bundle.js"></script>
|
<script src="bundle.js"></script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
Loading…
Reference in New Issue
Block a user