Browse Source

updated gulp

master
rdrew 2 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'; //@format
const yaml = require('js-yaml');
var gulp = require('gulp'); const fs = require('fs');
var browserSync = require('browser-sync').create(); const { SITE, PORT, BSREWRITE, PATHS } = loadConfig();
var imagemin = require('gulp-imagemin'); //var server = require('browser-sync').create();
var plumber = require('gulp-plumber'); //global.server = server;
var sass = require('gulp-sass'); const gulp = require('gulp');
var autoprefixer = require('gulp-autoprefixer'); const plumber = require('gulp-plumber');
var sourcemaps = require('gulp-sourcemaps'); const autoprefixer = require('gulp-autoprefixer');
var concat = require('gulp-concat'); const sass = require('gulp-sass')(require('sass'));
//var cache = require('gulp-cache'); 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
// Browsersync Proxy function bsInit(done) {
//=================== browsersync.init({
logLevel: 'debug',
proxy: 'https://roblib_2022.lndo.site'
});
done();
}
gulp.task('browser-sync', function() { function bsInit__remote(done) {
browserSync.init({ browsersync.init({
proxy: "http://rdm2.researchspaces.ca/", proxy: SITE.Remote.Url,
serveStatic: ['.'], serveStatic: ['.'],
files: ['./css/style.css','./js/rdm.js'], files: PATHS.Watch,
plugins: ['bs-rewrite-rules'], plugins: ['bs-rewrite-rules'],
rewriteRules: [ rewriteRules: [
{ {
match: '/themes/contrib/rdm_roblib/js/rdm.js', match: BSREWRITE.Css.Match,
replace: '/js/rdm.js' replace: BSREWRITE.Css.Replace
}, },
{ {
match: '/themes/contrib/rdm_roblib/css/style.css', match: BSREWRITE.Js.Match,
replace: '/css/style.css' replace: BSREWRITE.Js.Replace
} }
] ]
}); });
}); done();
}
// BrowserSync Reload
function bsReload(done) {
browsersync.reload();
done();
}
//==================== var cp = require('child_process');
// Sass Compilation function drush() {
//=================== return cp.exec('lando drush cr');
}
gulp.task('sass', function () { // Compile CSS
return gulp.src('./css/sass/**/*.scss') function styles() {
.pipe(sass({ 'use strict';
//includePaths: ['./node_modules/breakpoint-sass/stylesheets'] return gulp
})) .src(PATHS.Scss.Dir + '/**/*.scss')
.pipe(plumber())
.pipe(sourcemaps.init()) .pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError)) .pipe(
.pipe(sourcemaps.write('.')) sass
.pipe(gulp.dest('./css')); .sync({
}); includePaths: PATHS.Scss.Libraries
//====================
// 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}
]
}) })
])) .on('error', sass.logError)
.pipe(gulp.dest('img/')); )
}); .pipe(sourcemaps.write('.'))
.pipe(gulp.dest(PATHS.Css.Dir))
//================== .pipe(browsersync.stream());
// Default Gulp Task }
//=================
gulp.task ('default',['browser-sync'], function(){ // Watch Files
//watch sass folder and compile changes function watchFiles() {
gulp.watch('css/sass/**/*.scss', ['sass']); 'use strict';
//watch js folder and compile changes gulp.watch(PATHS.Scss.Dir + '/**/*.scss', styles);
gulp.watch('src/js/**/*.js', ['js']); gulp.watch('./templates/**/*.twig', drush);
//watch image folder and optimize }
gulp.watch('src/img/**/*', ['images']);
});
// 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", "version": "1.0.0",
"description": "", "description": "",
"main": "index.js", "main": "gulpfile.js",
"scripts": { "start": "node --experimental-modules gulpfile.js ",
"test": "echo \"Error: no test specified\" && exit 1" "directories": {
"test": "test"
}, },
"author": "",
"license": "ISC",
"devDependencies": { "devDependencies": {
"a11y-accordion-tabs": "^1.0.2",
"breakpoint-sass": "^2.7.1", "breakpoint-sass": "^2.7.1",
"browser-sync": "^2.24.7", "browser-sync": "latest",
"bs-rewrite-rules": "^2.1.2", "bs-rewrite-rules": "^2.1.2",
"gulp": "^3.9.1", "fs": "^0.0.1-security",
"gulp-autoprefixer": "^6.0.0", "gulp": "latest",
"gulp-cache": "^1.0.2", "gulp-autoprefixer": "latest",
"gulp-cache": "^1.1.3",
"gulp-concat": "^2.6.1", "gulp-concat": "^2.6.1",
"gulp-imagemin": "^4.1.0", "gulp-plumber": "latest",
"gulp-plumber": "^1.2.0", "gulp-rename": "latest",
"gulp-sass": "^4.0.1", "gulp-sass": "latest",
"gulp-sourcemaps": "^2.6.4" "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": { "dependencies": {
"accordionjs": "^2.1.2", "@fortawesome/fontawesome-free": "^6.0.0-beta3"
"natives": "^1.1.6"
} }
} }

Loading…
Cancel
Save