gulp

Is there a way to rewrite the HTML to use gulp-minified CSS

ⅰ亾dé卋堺 提交于 2019-11-29 20:10:25
I'm struggling with the following: My gulpfile.js compiles all .less, minifies it and concattenates all CSS into ./dist/all.min.css Is there a way I can rewrite the HTML file, remove all style tags and only put one style tag into it loading the minified CSS? OverZealous The best way to handle this is to use one of the HTML injectors from the get-go. I'm using gulp-inject to some success so far. Add gulp-inject to your project: npm i --save-dev gulp-inject Assuming that you have a folder layout similar to this: build/ src/ index.html less/ main.less js/ app.js Your HTML should include this

Gulp clean / del behaviour has changed

╄→尐↘猪︶ㄣ 提交于 2019-11-29 20:04:21
问题 Part of my gulpfile.js const del = require('del'); const chrome_dir = 'build/chrome'; const ff_dir = 'build/firefox'; gulp.task('clean', function (cb) { del([chrome_dir, ff_dir], cb); }); gulp.task('default', ['clean'], function () { gulp.start('build packages', 'JS Backend', 'i18n', 'ExtRes', 'styles', 'JS Content', 'templates'); }); worked well. Then I installed a new system and there maybe got new versions of gulp and del and whatever. Now gulp stops after cleaning. I can call all tasks

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

心已入冬 提交于 2019-11-29 19:47:55
In my gulpfile I have a version number in a string. I'd like to write the version number to a file. Is there a nice way to do this in Gulp, or should I be looking at more general NodeJS APIs? Christoph Neumann 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: function string_src(filename, string) { var src = require('stream').Readable({ objectMode: true }) src._read = function () { this.push(new gutil.File({ cwd: "", base

How to copy multiple files and keep the folder structure with Gulp

a 夏天 提交于 2019-11-29 19:30:58
I am trying to copy files from one folder to another folder using Gulp: gulp.task('move-css',function(){ return gulp.src([ './source/css/one.css', './source/other/css/two.css' ]).pipe(gulp.dest('./public/assets/css/')); }); The above code is copying one.css & two.css to the public/assets/css folder. And if I use gulp.src('./source/css/*.css') it will copy all CSS files to the public/assets/css folder which is not what I want. How do I select multiple files and keep the folder structure? Anulal S To achieve this please specify base . ¶ base - Specify the folder relative to the cwd. Default is

es6总结

允我心安 提交于 2019-11-29 19:10:26
一、ES5 ES6区别 1、let和var定义变量的区别 javascript 严格模式 第一次接触let关键字,有一个要非常非常要注意的概念就是”JavaScript 严格模式”,比如下述的代码运行就会报错: let hello = 'hello world.'; console.log(hello); 错误信息如下: let hello = 'hello world.'; ^^^ SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode ... 解决方法就是,在文件头添加”javascript 严格模式”声明: 'use strict'; let hello = 'hello world.'; console.log(hello); let和var关键字的异同 声明后未赋值,表现相同 'use strict'; (function() { var varTest; let letTest; console.log(varTest); //输出undefined console.log(letTest); //输出undefined }()); 使用未声明的变量,表现不同: (function() { console.log

Task Runners (Gulp, Grunt, etc) and Bundlers (Webpack, Browserify). Why use together?

牧云@^-^@ 提交于 2019-11-29 19:01:58
I am a bit new to the task runner and bundler world and while going through things like Grunt, Gulp, Webpack, Browserify , I did not feel that there is much difference between them. In other words, I feel Webpack can do everything that a task runner does. But still I got a huge examples where gulp and webpack are used together. I couldn't figure out the reason why. Being new to this, I might be taking things in the wrong direction. It will be great if you could point out what I am missing. Any useful links are welcome. Thanks in advance. Grunt and Gulp are actually task runners, and they have

gulp.run is deprecated. How do I compose tasks?

六月ゝ 毕业季﹏ 提交于 2019-11-29 18:58:42
Here is a composed task I don't know how to replace it with task dependencies. ... gulp.task('watch', function () { var server = function(){ gulp.run('jasmine'); gulp.run('embed'); }; var client = function(){ gulp.run('scripts'); gulp.run('styles'); gulp.run('copy'); gulp.run('lint'); }; gulp.watch('app/*.js', server); gulp.watch('spec/nodejs/*.js', server); gulp.watch('app/backend/*.js', server); gulp.watch('src/admin/*.js', client); gulp.watch('src/admin/*.css', client); gulp.watch('src/geojson-index.json', function(){ gulp.run('copygeojson'); }); }); The corresponding changelog https:/

Run one gulp task on multiple folders. The folders look like plugins/lsmwp-*

偶尔善良 提交于 2019-11-29 17:59:40
I create a lot of WordPress plugins, each of these all follow the same folder structure and all use Gulp to handle their SASS / JS assets. Folder Structure is as follows: |-- .gulpfile.js |-- lsmwp-one |-- plugin.php |-- assets |-- src |-- style.scss |-- dist |-- lsmwp-two |-- plugin.php |-- assets |-- src |-- style.scss |-- dist I would like to have a single Gulpfile that watches each 'lsmwp-*' folder, runs all related tasks and outputs to plugin dist folder. My Gulpfile currently watches these folders but I am having trouble setting the dest location. Any help would be appreciated. var

Making gulp write files synchronously before moving on to the next task

纵然是瞬间 提交于 2019-11-29 16:59:30
问题 gulpfile.js gulp.task('browser-bundle', ['react'], function() { ... }); gulp.task('react', function(){ gulp.src(options.JSX_SOURCE) .pipe(react()) .pipe(gulp.dest(options.JSX_DEST)) }); As you can see I have the browser-bundle task depending on the react task. I believe this works as expected because in the output I see this: [gulp] Running 'react'... [gulp] Finished 'react' in 3.43 ms [gulp] Running 'browser-bundle'... However, although the react task is finished, the files its supposed to

Bower component Quilljs editor module (ES6) is failing while running gulp build

我们两清 提交于 2019-11-29 16:48:32
I am getting the error events.js:160 throw er; // Unhandled 'error' event ^ Error: scripts/vendor.js: error: couldn't process source due to parse error 'import' and 'export' may appear only with 'sourceType: module' (176000:0) gulp file // gulp.task('bower', ['clean'], function () { gulp.start('bower:build'); }); gulp.task('bower:build', ['bower:scripts', 'bower:styles', 'bower:scss', 'bower:scripts:minify', 'bower:styles:minify']); gulp.task('bower:scripts', ['bower:partials'], function() { return gulp.src([ path.join(paths.src, '/app/triangular/**/*.js'), path.join(paths.tmp, 'partials',