Skip to content

Instantly share code, notes, and snippets.

@webmozart
Created September 23, 2015 15:26
Show Gist options
  • Save webmozart/8711cbffede16c8af1cd to your computer and use it in GitHub Desktop.
Save webmozart/8711cbffede16c8af1cd to your computer and use it in GitHub Desktop.
var gulp = require('gulp'),
sass = require('gulp-sass'),
concat = require('gulp-concat'),
puli = require('gulp-puli');
gulp.task('default', ['js', 'css', 'fonts']);
gulp.task('css', function () {
gulp.src(['node_modules/bootstrap-sass/assets/stylesheets/_bootstrap.scss', 'res/scss/style.scss'])
.pipe(concat('style.scss'))
.pipe(sass())
.pipe(gulp.dest('res/public/css/'));
});
gulp.task('puli', puli.publish());
/*
=
gulp.src('res/public')
.pipe(gulp.dest('web'));
gulp.src('vendor/batman/blog/res/public')
.pipe(gulp.dest('web/blog'));
*/
gulp.task('js', function () {
gulp.src([
'res/js/script.js',
'node_modules/jquery/dist/jquery.min.js',
'node_modules/bootstrap-sass/assets/javascripts/bootstrap.min.js'
])
.pipe(gulp.dest('res/public/js/'));
});
gulp.task('fonts', function () {
gulp.src('node_modules/bootstrap-sass/assets/fonts/bootstrap/*')
.pipe(gulp.dest('res/public/fonts/'));
});
gulp.task('watch', function () {
gulp.watch('res/scss/*.scss', ['css']);
gulp.watch('res/js/*.js', ['js']);
puli.watch(gulp, ['puli']);
/*
=
gulp.watch('res/public', ['puli']);
gulp.watch('vendor/batman/blog/res/public', ['puli']);
*/
});
<?php
/*
* This file is part of the puli/gulp-plugin package.
*
* (c) Bernhard Schussek <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Puli\GulpPlugin;
use Puli\Manager\Api\Event\PuliEvents;
use Puli\Manager\Api\Puli;
use Puli\Manager\Api\PuliPlugin;
use Puli\Repository\Api\Resource\FilesystemResource;
use Webmozart\PathUtil\Path;
/**
* Integrates Puli with the Gulp frontend workflow tool.
*
* @since 1.0
*
* @author Bernhard Schussek <[email protected]>
*/
class GulpPlugin implements PuliPlugin
{
/**
* {@inheritdoc}
*/
public function activate(Puli $puli)
{
$dispatcher = $puli->getEventDispatcher();
$repo = $puli->getRepository();
$assetManager = $puli->getAssetManager();
$serverManager = $puli->getServerManager();
foreach ($assetManager->getAssetMappings() as $mapping) {
$resource = $repo->get($mapping->getGlob());
if (!$resource instanceof FilesystemResource) {
// exception
}
$relPath = Path::makeRelative($resource->getFilesystemPath(), $puli->getRootDirectory());
$server = $serverManager->getServer($mapping->getServerName());
$serverPath = $server->getDocumentRoot().'/'.$mapping->getServerPath();
}
// Add event listeners that generate the JSON file here
$dispatcher->addListener(PuliEvents::XXX, array($this, 'handleXxx'));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment