1
0
mirror of https://github.com/NigelOToole/pixel-borders.git synced 2025-08-12 08:54:17 +02:00

Update to demo site tasks

This commit is contained in:
Nigel O'Toole
2019-06-12 16:10:29 +01:00
parent e5a792536a
commit 950e8db58e
2 changed files with 6 additions and 15 deletions

View File

@@ -5,15 +5,8 @@ const $ = gulpLoadPlugins();
const browserSync = require('browser-sync'); const browserSync = require('browser-sync');
const server = browserSync.create(); const server = browserSync.create();
const del = require('del'); const del = require('del');
const { argv } = require('yargs');
const autoprefixer = require('autoprefixer'); const autoprefixer = require('autoprefixer');
const port = argv.port || 9000;
const isProd = process.env.NODE_ENV === 'production';
const isTest = process.env.NODE_ENV === 'test';
const isDev = !isProd && !isTest;
const paths = { const paths = {
src: 'src', src: 'src',
dest: 'docs', dest: 'docs',
@@ -25,7 +18,7 @@ const paths = {
function styles() { function styles() {
return src(`${paths.src}/styles/*.scss`) return src(`${paths.src}/styles/*.scss`)
.pipe($.plumber()) .pipe($.plumber())
.pipe($.if(!isProd, $.sourcemaps.init())) .pipe($.sourcemaps.init())
.pipe($.sass.sync({ .pipe($.sass.sync({
outputStyle: 'expanded', outputStyle: 'expanded',
precision: 10, precision: 10,
@@ -35,7 +28,7 @@ function styles() {
.pipe($.postcss([ .pipe($.postcss([
autoprefixer() autoprefixer()
])) ]))
.pipe($.if(!isProd, $.sourcemaps.write())) .pipe($.sourcemaps.write())
.pipe(dest(`${paths.tmp}/styles`)) .pipe(dest(`${paths.tmp}/styles`))
.pipe(server.reload({stream: true})); .pipe(server.reload({stream: true}));
}; };
@@ -47,7 +40,7 @@ exports.styles = styles;
function startAppServer() { function startAppServer() {
server.init({ server.init({
notify: false, notify: false,
port, port: 9000,
server: { server: {
baseDir: [`${paths.tmp}`, `${paths.src}`], baseDir: [`${paths.tmp}`, `${paths.src}`],
routes: { routes: {
@@ -73,7 +66,7 @@ exports.serve = serve;
// ----- Build tasks ------ // ----- Build tasks ------
function compress() { function compress() {
return src([`${paths.src}/*.html`, `${paths.tmp}/*/**/*.{html,css,js}`]) return src([`${paths.tmp}/*/**/*.{html,css,js}`, `${paths.src}/**/*.{html,js,jpg,gif,png}`])
.pipe(dest(`${paths.dest}`)); .pipe(dest(`${paths.dest}`));
} }

View File

@@ -36,16 +36,14 @@
"del": "^3.0.0", "del": "^3.0.0",
"gulp": "^4.0.0", "gulp": "^4.0.0",
"gulp-cli": "^2.0.1", "gulp-cli": "^2.0.1",
"gulp-if": "^2.0.2",
"gulp-load-plugins": "^1.6.0", "gulp-load-plugins": "^1.6.0",
"gulp-plumber": "^1.0.1", "gulp-plumber": "^1.0.1",
"gulp-postcss": "^8.0.0", "gulp-postcss": "^8.0.0",
"gulp-sass": "^4.0.2", "gulp-sass": "^4.0.2",
"gulp-sourcemaps": "^2.2.0", "gulp-sourcemaps": "^2.2.0"
"yargs": "^12.0.5"
}, },
"scripts": { "scripts": {
"start": "gulp serve", "start": "gulp serve",
"build": "cross-env NODE_ENV=production gulp" "build": "gulp"
} }
} }