gulp

ES6 import module with Gulp

ぃ、小莉子 提交于 2019-12-08 15:41:25
问题 I am trying to import my ES6 module into a file and running Gulp to concat and minify the file. I'm running into a ReferenceError: require is not defined at all.js(transpiled) line no 3 . I have transpiled the code using gulp-babel. My js files are: cart.js: class Cart{ constructor(){ this.cart = []; this.items = items = [{ id: 1, name: 'Dove Soap', price: 39.99 },{ id: 2, name: 'Axe Deo', price: 99.99 }]; } getItems(){ return this.items; } } export {Cart}; app.js: import {Cart} from 'cart.js

Make gulp-uglify not mangle only one variable

随声附和 提交于 2019-12-08 14:58:09
问题 I just wanted to check if there is a way to mangle variables except a specific one for Gulp-Uglify. If there isn't, is there a work-around to achieve the effect I desire? Thanks. 回答1: There definitely is, I couldn't find any documentation for gulp-uglify regarding these sub-options, so relied on grunt-uglify & wrote it the gulp way. .pipe( uglify({ mangle: {except: ['jQuery']} }) ) // for gulp-uglify ^2.0.1 The above code will mangle every variable except jQuery Hopefully this will still be

Testem gulp task hangs after finished

一笑奈何 提交于 2019-12-08 13:46:39
问题 This gulp task doesn't exit after finished, I have to manually press Ctrl-C to exit. gulp.task('test', function(done) { var testem = require('testem'); var testemOptions = { file: 'testem.json' }; var t = new testem(); t.startCI(testemOptions, done); }); How can i make this task exit properly? Note: Actually it exits itself, but it takes like 15 seconds after finished. Output: [15:49:59] Using gulpfile ~/gulpfile.js [15:49:59] Starting 'test'... ok 1 PhantomJS 1.9 - Integration Tests: Home

Converting es6 script to JS using gulp

久未见 提交于 2019-12-08 13:46:22
问题 I am trying to convert the ES6 code to simple JS, using babel in gulp. Running the below code I am getting [Error in Plugin "gulp-babel"] with Message: [Plugin/Preset files are not allowed to export objects, only functions.] var gulp = require('gulp'); var babel = require('gulp-babel'); gulp.task('scripts',function(){ return gulp.src(['src/scripts/app.js']) .pipe(babel({presets:['es2015']})) .pipe(gulp.dest('build/scripts/')) }); src/scripts/app.js const hello = (name) => { return `hello $

Tell npm to look for node_modules inside a different dir

天大地大妈咪最大 提交于 2019-12-08 13:28:56
问题 npm looks for node_modules in the current directory, and all its parent directories, then looks in the global location. My current proposed dir structure is: global package.json node_modules/ project-1 gulpfile.coffee project-2 gulpfile.coffee But this isn't where npm normally looks for this. Is there an environment variable I can set to deal with this, or a way I can tell it to look in a specific directory? Thanks! 回答1: Try the following to set NODE_PATH in gulp. .pipe(preprocess({context: {

Delay in gulp watch

梦想与她 提交于 2019-12-08 12:50:52
问题 Currently I'm working true ftp and running gulp watch on te server, now te problem is that when my gulp watch is detecting changes the file is not ready with uploading, so I need to have a delay in my gulp watch. gulp.task('watch', function() { setTimeout(function() { gulp.watch(config.js.app.pathIn + '/**/*.js', ['js_app']); gulp.watch(config.js.vendor.pathIn + '/**/*.js', ['js_vendor']); gulp.watch(config.scss.pathIn + '/**/*.scss', ['scss']); }, 3000); }); This is not delaying the

Specify --json in webpack config instead of command line

大憨熊 提交于 2019-12-08 11:48:18
问题 I'm using Webpack 4 via webpack-stream / gulp. I'd like to write stats as a JSON file, like I would with webpack --json > stats.json , but using my current tooling. Ideally, I would simply set the option in the config object I pass to webpack-stream, but I'm open to other options. 回答1: It just so happens I'm using webpack-bundle-analyzer, which provides the option to write out stats.json for me. Here's the config: { // ... plugins: [ new analyzer.BundleAnalyzerPlugin({ // writes to <webpack

Browsersync not reloading all pages

醉酒当歌 提交于 2019-12-08 11:46:18
问题 Browsersync is just reloading index.html, even though I have my basedir set, and even the specific files listed on the files option. I have looked on their docu but I have everything as they say, still it only refreshed or syncs index.hrml but about.html for example not. My structure is this: -booming-gaes-web -dist -node_modules -src -index.html -about.html -gulpfile.js So my html files are direclty on my src folder, and the gulp file is in the same folder as the src folder. My gulp file: //

Is it possible to setup Gulp in a distributed fashion?

淺唱寂寞╮ 提交于 2019-12-08 11:28:01
问题 Here's what I want to do: Create a node package that features the following: gulpfile.js All gulp plugins, tasks, configs. Install this node package (referred to as "my-gulp" from here on) within an Angular app (referred to as "myApp" from here on) via package.json dependencies. gulpfile.js is copied into app root. All Gulp tasks can be run from app. We currently have something similar setup with Grunt (although without the Gruntfile.js copy stuff). It works pretty well to have a common setup

Gulp: Rename certain file from source directory while copying

℡╲_俬逩灬. 提交于 2019-12-08 11:26:13
问题 I would like to copy a folder to another destination and rename a certain file in the same process. gulp.task('deploy', function () { gulp.src(['xxx/**/*']).pipe(gulp.dest('yyy')); }); I am able to copy the folder over just fine but how would I go about renaming the file? Source folder structure: - xxx (root) - scripts - config - app.config.local.js (would like to rename this file as app.config.js) - app.config.dev.js 回答1: You can use the gulp-rename plugin to rename files and the gulp-if