cannot find module “lodash”

Be sure to install lodash in the required folder. This is probably your C:\gwsk directory. If that folder has a package.json file, it is also best to add –save behind the install command. $ npm install lodash –save The package.json file holds information about the project, but to keep it simple, it holds your project … Read more

How can Gulp be restarted upon each Gulpfile change?

You can create a task that will gulp.watch for gulpfile.js and simply spawn another gulp child_process. var gulp = require(‘gulp’), argv = require(‘yargs’).argv, // for args parsing spawn = require(‘child_process’).spawn; gulp.task(‘log’, function() { console.log(‘CSSs has been changed’); }); gulp.task(‘watching-task’, function() { gulp.watch(‘*.css’, [‘log’]); }); gulp.task(‘auto-reload’, function() { var p; gulp.watch(‘gulpfile.js’, spawnChildren); spawnChildren(); function spawnChildren(e) { … Read more

Gulp minify multiple js files to one

This plugin will help gulp-concat. Usage: var concat = require(‘gulp-concat’); gulp.task(‘scripts’, function() { gulp.src([‘./lib/file3.js’, ‘./lib/file1.js’, ‘./lib/file2.js’]) .pipe(concat(‘all.js’)) .pipe(uglify()) .pipe(gulp.dest(‘./dist/’)) });

How can I set an environment variable as gulp task?

gulp.task(‘set-dev-node-env’, function() { return process.env.NODE_ENV = ‘development’; }); gulp.task(‘set-prod-node-env’, function() { return process.env.NODE_ENV = ‘production’; }); Use it like: gulp.task(‘build_for_prod’, [‘set-prod-node-env’], function() { // maybe here manipulate config object config.paths.src.scripts = config.paths.deploy.scripts; runSequence( ‘build’, ‘s3’ ); });

Uglify SyntaxError: Unexpected token: punc ())

// Update From the comments ~ @imolit  v2.0.0 (2018-09-14) – BREAKING CHANGES (link) Switch back to uglify-js (uglify-es is abandoned, if you need uglify ES6 code please use terser-webpack-plugin). Original answer before the update… I hope you can get inspired by this solution which works with webpack. (link below) Simply teach UglifyJS ES6 There are two … Read more

How to Gulp-Watch Multiple files?

gulp.task(‘default’, [‘css’, ‘browser-sync’] , function() { gulp.watch([‘sass/**/*.scss’, ‘layouts/**/*.css’], [‘css’]); }); sass/**/*.scss and layouts/**/*.css will watch every directory and subdirectory for any changes to .scssand .css files that change. If you want to change that to any file make the last bit *.*

How do you create a file from a string in Gulp?

If you’d like to do this in a gulp-like way, you can create a stream of “fake” vinyl files and call pipe per usual. Here’s a function for creating the stream. “stream” is a core module, so you don’t need to install anything: const Vinyl = require(‘vinyl’) function string_src(filename, string) { var src = require(‘stream’).Readable({ … Read more

Browserify, Babel 6, Gulp – Unexpected token on spread operator

That syntax is an experimental proposed syntax for the future, it is not part of es2015 or react so you’ll need to enable it. npm install –save-dev babel-plugin-transform-object-rest-spread and add “plugins”: [“transform-object-rest-spread”] into .babelrc alongside your existing presets. Alternatively: npm install –save-dev babel-preset-stage-3 and use stage-3 in your presets to enable all stage-3 experimental functionality.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)