Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
gulp.task('scss', function () {
return gulp.src(config.paths.scss + '**/*.scss')
.pipe(gulpif(argv.debug === true, debug({title: 'CSS Processed:'})))
.pipe(gulpif(!argv.production, sourcemaps.init())) // Sourcemaps if there is no production flag
.pipe(sass(eyeglass.sassOptions()).on('error', sass.logError))
.pipe(postcss(processors))
.pipe(gulpif(!argv.production, sourcemaps.write('.'))) // Sourcemaps if there is no production flag
.pipe(gulp.dest(config.paths.buildAssets + 'css'))
.pipe(browserSync.stream({match: '**/*.css'}));
});
const strip = require('rollup-plugin-strip');
const flow = require('rollup-plugin-flow');
const rollup = require('rollup');
const glob = require("glob");
const servicePlugins = [
flow({ all: true }),
babel({
babelrc: false,
presets: [
[ "env", { "modules": false } ]
],
}),
];
if (argv.production) {
servicePlugins.push(
strip({
debugger: true,
functions: [ 'console.*', 'assert.*' ],
})
);
// fwPlugins.push(
// uglify({
// warnings: false
// })
// );
}
function buildBundle(bundleConfig) {
return rollup.rollup(bundleConfig.input)
.then(function(bundle) {
var buffer = require('vinyl-buffer');
var argv = require('yargs').argv;
// sass
var sass = require('gulp-sass');
var postcss = require('gulp-postcss');
var autoprefixer = require('autoprefixer');
var sourcemaps = require('gulp-sourcemaps');
// js
var watchify = require('watchify');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var babelify = require('babelify');
var envify = require('envify');
// gulp build --production
var production = !!argv.production;
// determine if we're doing a build
// and if so, bypass the livereload
var build = argv._.length ? argv._[0] === 'build' : false;
var watch = argv._.length ? argv._[0] === 'watch' : true;
// ----------------------------
// Error notification methods
// ----------------------------
var handleError = function(task) {
return function(err) {
notify.onError({
message: task + ' failed, check the logs..',
sound: false
})(err);
gutil.log(gutil.colors.bgRed(task + ' error:'), gutil.colors.red(err));
gulp.task('styles', function() {
var isProduction = (typeof argv.production !== 'undefined') ? true : false;
return gulp.src(config.src.scss + '/**/*.{sass,scss}')
.pipe(plumber(function(error) {
notify.onError(function (error) {
return error.message;
});
}))
.pipe(globbing({
extensions: ['.scss']
}))
.pipe(gulpif(!isProduction, sourcemaps.init()))
.pipe(sass({
outputStyle: isProduction ? 'compressed' : 'expanded'
}))
.pipe(autoprefixer({
browsers: config.browsers
gulp.task('build',['clean'], function() {
argv.production = true;
return gulp.start('vendors', 'styles', 'img', 'scripts');
});
export default async function copy() {
const indexFile = argv.production ? 'index' : 'index-dev';
await fs.copy('./node_modules/kakapo-assets/icomoon/fonts', 'build/fonts');
await fs.copy('app/fonts', 'build/fonts');
if (argv.platform === 'desktop') {
proc.execSync('babel app/browser.js --out-file build/browser.js');
await fs.copy('package.json', 'build/package.json');
await fs.copy(`app/html/desktop/${indexFile}.html`, 'build/index.html');
await fs.copy('./node_modules/kakapo-assets/sounds', 'build/sounds', {
filter: str => !!str.match(/.ogg$/i)
});
await fs.copy('./node_modules/kakapo-assets/data', 'build/data');
}
if (argv.platform === 'web') {
await fs.copy(`app/html/web/${indexFile}.html`, 'build/index.html');
function argOptions() {
return {
rev: !!(args.rev || args.production),
minify: !!(args.minify || args.production),
production: !!args.production,
verbose: !!(args.verbose || args.v),
startServer: !!args.startServer,
debug: !!(args.debug || args.debugBrk),
debugBrk: !!args.debugBrk,
nosync: !!args.nosync,
type: args.type,
version: args.version
};
}
gulp.task('scss', function(cb) {
pump([
gulp.src(config.watch.scss),
sass({
outputStyle: 'expanded',
}).on('error', sass.logError),
autoprefixer('last 2 versions'),
gulpif(args.production, cssnano({
minifyFontValues: false,
discardComments: {removeAll: true},
zindex: false,
})),
gulp.dest(config.dest.css),
], cb);
});