-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from Roky97/gulp-integration
Gulp integration - Release 2.8.0
- Loading branch information
Showing
8 changed files
with
210 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
const { series, src, dest, parallel } = require('gulp'); | ||
const csso = require('gulp-csso'); | ||
const shorthand = require('gulp-shorthand'); | ||
const clean = require('gulp-clean'); | ||
const autoprefixer = require('gulp-autoprefixer'); | ||
const uglify = require('gulp-uglify-es').default; | ||
const imagemin = require('gulp-imagemin'); | ||
const nodemon = require('gulp-nodemon') | ||
var browserSync = require('browser-sync').create(); | ||
|
||
const path = { | ||
dist: 'dist/', | ||
src: 'resources/' | ||
} | ||
|
||
const environment = { | ||
dev: 'development', | ||
prod: 'production' | ||
} | ||
|
||
// System config loading | ||
var properties = require('./config/app-config.json'); | ||
var httpPort = properties.port.http; | ||
|
||
function cleanDir(){ | ||
return src( path.dist + '*', {read: false}) | ||
.pipe(clean()); | ||
} | ||
|
||
function css() { | ||
return src(path.src + 'css/*.css') | ||
.pipe(autoprefixer({ | ||
cascade: false | ||
})) | ||
.pipe(shorthand()) | ||
.pipe(csso()) | ||
.pipe(dest(path.dist + 'css/')) | ||
} | ||
|
||
function faviconImage() { | ||
return src(path.src + 'favicon/*.{png,svg}') | ||
.pipe(imagemin()) | ||
.pipe(dest(path.dist + 'favicon/')) | ||
} | ||
|
||
function faviconFiles() { | ||
return src(path.src + 'favicon/*.{ico,xml,webmanifest}') | ||
.pipe(dest(path.dist + 'favicon/')) | ||
} | ||
|
||
function img() { | ||
return src(path.src + 'img/*.*') | ||
.pipe(imagemin()) | ||
.pipe(dest(path.dist + 'img/')) | ||
} | ||
|
||
function js() { | ||
return src(path.src + 'js/**/*.js') | ||
.pipe(uglify()) | ||
.pipe(dest(path.dist + 'js/')) | ||
} | ||
|
||
function pug() { | ||
return src(path.src + '**/*.pug') | ||
.pipe(dest(path.dist)) | ||
} | ||
|
||
function serveProd(done) { | ||
const server = nodemon({ | ||
script: 'app.js' | ||
, ext: 'js json' | ||
, ignore: ['node_modules/', 'dist/', 'resources/', 'gulpfile.js'] | ||
, env: { 'NODE_ENV': environment.prod } | ||
}); | ||
|
||
server.on('start', () => { | ||
done(); | ||
}); | ||
} | ||
|
||
function serveDev(done) { | ||
const STARTUP_TIMEOUT = 5000; | ||
const server = nodemon({ | ||
script: 'app.js' | ||
, stdout: false | ||
, ext: 'js json' | ||
, ignore: ['node_modules/', 'dist/', 'resources/', 'gulpfile.js'] | ||
, env: { 'NODE_ENV': environment.dev } | ||
}); | ||
let starting, restarting, crashed = false; | ||
|
||
const onReady = () => { | ||
starting = false; | ||
if(restarting && !crashed) browserSync.reload(); | ||
restarting = false; | ||
crashed = false; | ||
done(); | ||
}; | ||
|
||
server.on('start', () => { | ||
starting = true; | ||
setTimeout(onReady, STARTUP_TIMEOUT); | ||
}); | ||
|
||
server.on('stdout', (stdout) => { | ||
process.stdout.write(stdout); // pass the stdout through | ||
if (starting || restarting) { | ||
onReady(); | ||
} | ||
}); | ||
|
||
server.on('restart', () => { | ||
browserSync.notify("Reastarting LoIDE, please wait!"); | ||
restarting = true; | ||
}); | ||
|
||
server.on('crash', () => { | ||
browserSync.notify("LoIDE crashed!", 5000); | ||
crashed = true; | ||
}); | ||
} | ||
|
||
function startBrowserSync(done){ | ||
browserSync.init({ | ||
proxy: "http://localhost:" + httpPort, | ||
files: [path.src + "/**/*.*"], | ||
port: 7000, | ||
}, done); | ||
} | ||
|
||
const build = parallel(css,faviconImage,faviconFiles,img,js,pug); | ||
|
||
exports.default = series(cleanDir, build, serveProd) | ||
exports.dev = series(cleanDir, serveDev, startBrowserSync) | ||
exports.clean = series(cleanDir) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -140,7 +140,7 @@ | |
</div> | ||
<div class="container"> | ||
<form id="input" style="position: relative;"> | ||
<div class="left-panel" style="height: auto"> | ||
<div class="left-panel left-panel-show" style="height: auto"> | ||
<div class="option-solver"> | ||
<div class="text-center left-panel-title sticky-top pt-2 mb-2"> | ||
<h5>Run options</h5> | ||
|
@@ -409,7 +409,7 @@ | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script> | ||
<script src="https://code.jquery.com/jquery-migrate-3.3.0.min.js"></script> | ||
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script> | ||
<script src="js/jquery.layout_and_plugins.min.js" type="text/javascript"></script> | ||
<script src="js/plugin/jquery.layout_and_plugins.min.js" type="text/javascript"></script> | ||
|
||
<!-- Bootstrap JavaScript --> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script> | ||
|
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters