Skip to content
This repository was archived by the owner on Feb 28, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,23 @@ browserify: {
}
```

### webpack
configured using standard webpack configuration.

```js
webpack: {
//see https://webpack.github.io/docs/
//alternatively you can require your webpack-config: require('webpack.config.js');
},
```

### bower
builds your bower dependencies defined in your local bower.json
builds your bower dependencies defined in your local bower.json into the defined directory.
afterwards copies them into dest.

```js
bower: {
directory: "vendors/.bower", //your bower install directory
dest: "public/vendors" //your public/lib directory
dest: "public/vendors" //your public/lib directory (optional)
}
```
6 changes: 5 additions & 1 deletion example/gulp_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,13 @@ module.exports = {
plugins: {
}
},
webpack: {
//see https://webpack.github.io/docs/
//alternatively you can require your webpack-config: require('webpack.config.js');
},
bower: {
directory: "./my_bower_components",
dest: ""
dest: "public/vendors"
},
copy: [
{
Expand Down
2 changes: 1 addition & 1 deletion gulp/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var path = require('path');
* Do not change.
* @type {string}
*/
global.projectPath = './project';
global.projectPath = '/home/gulp/project';
global.config = require(projectPath + '/gulp_config');

requireDir('./tasks', {recurse: true});
Expand Down
3 changes: 3 additions & 0 deletions gulp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
"gulp-bower": "^0.0.13",
"browserify": "^13.0.0",
"watchify": "^3.7.0",
"webpack": "^1.13.1",
"json-loader": "^0.5.4",
"ractivejs-loader": "git://github.com/ipunkt/ractivejs-loader",
"ractive": "git://github.com/ractivejs/ractive#build",
"ractify": "^0.6.0",
"merge-stream": "^1.0.0",
Expand Down
9 changes: 6 additions & 3 deletions gulp/tasks/bower.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ var path = require('path');
var paths = {
directory: config.bower.directory,
cwd: projectPath,
dest: path.join(projectPath,config.bower.dest)
dest: config.bower.dest ? path.join(projectPath,config.bower.dest) : false
};

function bowerTask() {
return bower({directory: paths.directory, cwd: paths.cwd})
.pipe(gulp.dest(paths.dest));
var b = bower({directory: paths.directory, cwd: paths.cwd});
if (paths.dest !== false) {
b.pipe(gulp.dest(paths.dest));
}
return b;
}

gulp.task('bower', function() {
Expand Down
45 changes: 45 additions & 0 deletions gulp/tasks/webpack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
'use strict';

if(!config.webpack) return;

var gulp = require("gulp");
var gutil = require("gulp-util");
var webpack = require("webpack");

function webpackTask(watch, callback) {
//chdir to our project path to make webpack work as intended
var oldPath = process.cwd();
process.chdir(projectPath);

//setup webpack
var w = webpack(config.webpack);

function webpackCallback(err, stats) {
if (err) throw new gutil.PluginError("webpack", err);
gutil.log("[webpack]", stats.toString());
callback();
}

//run webpack either in watch mode or normal (once)
if (watch) {
w.watch({
aggregateTimeout: 500,
poll: 500
}, webpackCallback);
} else {
w.run(webpackCallback);
}

//go back to our old path
process.chdir(oldPath);
}


gulp.task("webpack", function(callback) {
return webpackTask(false, callback);
});


gulp.task("webpack:watch", function(callback) {
return webpackTask(true, callback);
});