Browse Source

updated gulp

master
rdrew 3 years ago
parent
commit
4c20d7fda0
  1. 8
      .gitignore
  2. 38
      config.yml
  3. 150
      gulpfile.js
  4. 96
      oldgulp/gulpfile.js
  5. 9394
      oldgulp/package-lock.json
  6. 28
      oldgulp/package.json
  7. 17020
      package-lock.json
  8. 44
      package.json

8
.gitignore vendored

@ -0,0 +1,8 @@
# Ignore the node modules folder (created by 'npm install').
node_modules
# We absolutely don't want to have the .sass-cache in git.
.sass-cache
.DS_Store
*.swo

38
config.yml

@ -0,0 +1,38 @@
SITE:
Local: 'https://rdm_upei.lndo.site/'
Remote:
Url: 'https://rdm2.researchspaces.ca/'
Path: user
PORT: 8000
BSREWRITE:
Css:
Match: "/themes/contrib/RDM/css/"
Replace: "/css/"
Js:
Match: "/themes/contrib/RDM/js/"
Replace: "/js/"
PATHS:
Watch:
#changes in these compiled files trigged reload
- ./css/*.css
- ./js/*.js
Scss:
Dir: ./css/sass
Libraries:
#- libraries/guff
#- bower_components/foundation-sites/scss
#- bower_components/motion-ui/src
#- node_modules/modularscale-sass/stylesheets
#- libraries/fontawesome-free/scss
Css:
Dir: css
#FileName: app.css
Js:
Src: ./js/src/*.js
Dest: js
FileName: 'ia-islandimagined.behaviors.js'
Img:
Src: img/src
Dest: img

150
gulpfile.js

@ -1,96 +1,94 @@
'use strict';
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var imagemin = require('gulp-imagemin');
var plumber = require('gulp-plumber');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var sourcemaps = require('gulp-sourcemaps');
var concat = require('gulp-concat');
//var cache = require('gulp-cache');
//@format
const yaml = require('js-yaml');
const fs = require('fs');
const { SITE, PORT, BSREWRITE, PATHS } = loadConfig();
//var server = require('browser-sync').create();
//global.server = server;
const gulp = require('gulp');
const plumber = require('gulp-plumber');
const autoprefixer = require('gulp-autoprefixer');
const sass = require('gulp-sass')(require('sass'));
const browsersync = require('browser-sync').create();
const sourcemaps = require('gulp-sourcemaps');
function loadConfig() {
var ymlFile = fs.readFileSync('config.yml', 'utf8');
return yaml.load(ymlFile);
}
//===================
// Browsersync Proxy
//===================
// BrowserSync
function bsInit(done) {
browsersync.init({
logLevel: 'debug',
proxy: 'https://roblib_2022.lndo.site'
});
done();
}
gulp.task('browser-sync', function() {
browserSync.init({
proxy: "http://rdm2.researchspaces.ca/",
function bsInit__remote(done) {
browsersync.init({
proxy: SITE.Remote.Url,
serveStatic: ['.'],
files: ['./css/style.css','./js/rdm.js'],
files: PATHS.Watch,
plugins: ['bs-rewrite-rules'],
rewriteRules: [
{
match: '/themes/contrib/rdm_roblib/js/rdm.js',
replace: '/js/rdm.js'
match: BSREWRITE.Css.Match,
replace: BSREWRITE.Css.Replace
},
{
match: '/themes/contrib/rdm_roblib/css/style.css',
replace: '/css/style.css'
match: BSREWRITE.Js.Match,
replace: BSREWRITE.Js.Replace
}
]
});
});
done();
}
// BrowserSync Reload
function bsReload(done) {
browsersync.reload();
done();
}
//====================
// Sass Compilation
//===================
var cp = require('child_process');
function drush() {
return cp.exec('lando drush cr');
}
gulp.task('sass', function () {
return gulp.src('./css/sass/**/*.scss')
.pipe(sass({
//includePaths: ['./node_modules/breakpoint-sass/stylesheets']
}))
// Compile CSS
function styles() {
'use strict';
return gulp
.src(PATHS.Scss.Dir + '/**/*.scss')
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('./css'));
});
//====================
// JS Concatination
//===================
gulp.task('js', function () {
gulp.src('./src/js/*.js') // path to your files
.pipe(concat('js.js')) // concat and name it "concat.js"
.pipe(gulp.dest('./js/'));
});
//====================
// Image Optimization
//===================
gulp.task('images', function(){
gulp.src('src/img/**/*')
//.pipe(imagemin({ optimizationLevel: 3, progressive: true, interlaced: true }))
.pipe(imagemin([
imagemin.jpegtran({progressive: true}),
imagemin.optipng({optimizationLevel: 5}),
imagemin.svgo({
plugins: [
{removeViewBox: true},
{cleanupIDs: false}
]
.pipe(
sass
.sync({
includePaths: PATHS.Scss.Libraries
})
]))
.pipe(gulp.dest('img/'));
});
//==================
// Default Gulp Task
//=================
.on('error', sass.logError)
)
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(PATHS.Css.Dir))
.pipe(browsersync.stream());
}
gulp.task ('default',['browser-sync'], function(){
//watch sass folder and compile changes
gulp.watch('css/sass/**/*.scss', ['sass']);
//watch js folder and compile changes
gulp.watch('src/js/**/*.js', ['js']);
//watch image folder and optimize
gulp.watch('src/img/**/*', ['images']);
});
// Watch Files
function watchFiles() {
'use strict';
gulp.watch(PATHS.Scss.Dir + '/**/*.scss', styles);
gulp.watch('./templates/**/*.twig', drush);
}
// Group complex tasks
const build = gulp.parallel(styles);
const watch = gulp.series(styles, gulp.parallel(watchFiles, bsInit));
// Export tasks
exports.build = build;
exports.styles = styles;
exports.drush = drush;
exports.watch = watch;
exports.default = watch;

96
oldgulp/gulpfile.js

@ -0,0 +1,96 @@
'use strict';
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var imagemin = require('gulp-imagemin');
var plumber = require('gulp-plumber');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var sourcemaps = require('gulp-sourcemaps');
var concat = require('gulp-concat');
//var cache = require('gulp-cache');
//===================
// Browsersync Proxy
//===================
gulp.task('browser-sync', function() {
browserSync.init({
proxy: "http://rdm2.researchspaces.ca/",
serveStatic: ['.'],
files: ['./css/style.css','./js/rdm.js'],
plugins: ['bs-rewrite-rules'],
rewriteRules: [
{
match: '/themes/contrib/rdm_roblib/js/rdm.js',
replace: '/js/rdm.js'
},
{
match: '/themes/contrib/rdm_roblib/css/style.css',
replace: '/css/style.css'
}
]
});
});
//====================
// Sass Compilation
//===================
gulp.task('sass', function () {
return gulp.src('./css/sass/**/*.scss')
.pipe(sass({
//includePaths: ['./node_modules/breakpoint-sass/stylesheets']
}))
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('./css'));
});
//====================
// JS Concatination
//===================
gulp.task('js', function () {
gulp.src('./src/js/*.js') // path to your files
.pipe(concat('js.js')) // concat and name it "concat.js"
.pipe(gulp.dest('./js/'));
});
//====================
// Image Optimization
//===================
gulp.task('images', function(){
gulp.src('src/img/**/*')
//.pipe(imagemin({ optimizationLevel: 3, progressive: true, interlaced: true }))
.pipe(imagemin([
imagemin.jpegtran({progressive: true}),
imagemin.optipng({optimizationLevel: 5}),
imagemin.svgo({
plugins: [
{removeViewBox: true},
{cleanupIDs: false}
]
})
]))
.pipe(gulp.dest('img/'));
});
//==================
// Default Gulp Task
//=================
gulp.task ('default',['browser-sync'], function(){
//watch sass folder and compile changes
gulp.watch('css/sass/**/*.scss', ['sass']);
//watch js folder and compile changes
gulp.watch('src/js/**/*.js', ['js']);
//watch image folder and optimize
gulp.watch('src/img/**/*', ['images']);
});

9394
oldgulp/package-lock.json generated

File diff suppressed because it is too large Load Diff

28
oldgulp/package.json

@ -0,0 +1,28 @@
{
"name": "bs",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"breakpoint-sass": "^2.7.1",
"browser-sync": "^2.24.7",
"bs-rewrite-rules": "^2.1.2",
"gulp": "^3.9.1",
"gulp-autoprefixer": "^6.0.0",
"gulp-cache": "^1.0.2",
"gulp-concat": "^2.6.1",
"gulp-imagemin": "^4.1.0",
"gulp-plumber": "^1.2.0",
"gulp-sass": "^4.0.1",
"gulp-sourcemaps": "^2.6.4"
},
"dependencies": {
"accordionjs": "^2.1.2",
"natives": "^1.1.6"
}
}

17020
package-lock.json generated

File diff suppressed because it is too large Load Diff

44
package.json

@ -1,28 +1,40 @@
{
"name": "bs",
"name": "robs-gulp",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"main": "gulpfile.js",
"start": "node --experimental-modules gulpfile.js ",
"directories": {
"test": "test"
},
"author": "",
"license": "ISC",
"devDependencies": {
"a11y-accordion-tabs": "^1.0.2",
"breakpoint-sass": "^2.7.1",
"browser-sync": "^2.24.7",
"browser-sync": "latest",
"bs-rewrite-rules": "^2.1.2",
"gulp": "^3.9.1",
"gulp-autoprefixer": "^6.0.0",
"gulp-cache": "^1.0.2",
"fs": "^0.0.1-security",
"gulp": "latest",
"gulp-autoprefixer": "latest",
"gulp-cache": "^1.1.3",
"gulp-concat": "^2.6.1",
"gulp-imagemin": "^4.1.0",
"gulp-plumber": "^1.2.0",
"gulp-sass": "^4.0.1",
"gulp-sourcemaps": "^2.6.4"
"gulp-plumber": "latest",
"gulp-rename": "latest",
"gulp-sass": "latest",
"gulp-sourcemaps": "^3.0.0",
"gulp4-run-sequence": "^1.0.0",
"js-yaml": "^4.1.0",
"modularscale-sass": "^3.0.10",
"natives": "^1.1.6",
"require-dir": "^1.2.0",
"run-sequence": "^2.2.1",
"sass": "^1.44.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"accordionjs": "^2.1.2",
"natives": "^1.1.6"
"@fortawesome/fontawesome-free": "^6.0.0-beta3"
}
}

Loading…
Cancel
Save