Set up Gulpfile

master
Bruno Dias 8 years ago
parent 56661f62f6
commit 56a2a0ad68

4
.gitignore vendored

@ -1 +1,3 @@
node_modules
node_modules
build
dist

@ -0,0 +1,132 @@
'use strict';
/* Raconteur Gulpfile scaffold. */
/* Includes code adapted from Gulp documentation, among other sources. */
/* Imports */
var watchify = require('watchify'),
browserify = require('browserify'),
browserSync = require('browser-sync'),
gulp = require('gulp'),
source = require('vinyl-source-stream'),
gutil = require('gulp-util'),
coffeify = require('coffeeify'),
less = require('gulp-less'),
minifyCSS = require('gulp-minify-css'),
uglify = require('gulp-uglify'),
buffer = require('vinyl-buffer'),
_ = require('lodash');
var reload = browserSync.reload;
/* Tasks */
/* Trivial file copies */
function html (target) {
return function () {
return gulp.src('html/index.html')
.pipe(gulp.dest(target));
};
}
function img (target) {
return function () {
return gulp.src(['img/*.png', 'img/*.jpeg', 'img/*.jpg'])
.pipe(gulp.dest(target));
};
}
gulp.task('html', html('./build'));
gulp.task('img', img('./build/img'));
/* Less */
gulp.task('less', function () {
gulp.src('less/main.less')
.pipe(less())
.pipe(gulp.dest('./build/css'));
});
/* Generate JavaScript with browser sync. */
var customOpts = {
entries: ['./game/main.coffee'],
debug: true,
transform: [coffeify]
};
var opts = _.assign({}, watchify.args, customOpts);
var bundler = watchify(browserify(opts));
gulp.task('coffee', bundle); // `gulp coffee` will generate bundle
bundler.on('update', bundle); // Re-bundle on dep updates
bundler.on('log', gutil.log); // Output build logs to terminal
function bundle () {
return bundler.bundle()
.on('error', gutil.log.bind(gutil, 'Browserify Error'))
.pipe(source('bundle.js'))
.pipe(gulp.dest('./build/game'));
};
/* Make a development build */
gulp.task('build', ['html', 'img', 'less', 'coffee'], function () {
});
/* Start a development server */
gulp.task('serve', ['build'], function () {
browserSync({
server: {
baseDir: 'build'
}
});
var lessListener = function () {
reload('./build/css/main.css');
}
gulp.watch(['./html/*.html'], ['html']);
gulp.watch(['./less/*.less'], ['less']);
gulp.watch(['./img/*.png', './img/*.jpeg', './img/*.jpg'], ['img']);
gulp.watch(['./build/css/main.css'], lessListener);
gulp.watch(
['./build/game/bundle.js', './build/img/*', './build/index.html'],
browserSync.reload);
});
/* Distribution tasks */
gulp.task('html-dist', html('./dist'));
gulp.task('img-dist', img('./dist/img'));
gulp.task('less-dist', function () {
return gulp.src('./less/main.less')
.pipe(less())
.pipe(minifyCSS())
.pipe(gulp.dest('./dist/css'));
});
var distBundler = browserify({
debug: false,
entries: ['./game/main.coffee'],
transform: ['coffeeify']
});
gulp.task('coffee-dist', function () {
return distBundler.bundle()
.pipe(source('bundle.js'))
.pipe(buffer())
.pipe(uglify())
.on('error', gutil.log)
.pipe(gulp.dest('./dist/game'));
});
gulp.task('dist', ['html-dist', 'img-dist', 'less-dist', 'coffee-dist'],
function () {
return;
});

@ -1,12 +1,11 @@
# Require the libraries we rely on
situation = require('raconteur/lib/situation.js')
situation.exportUndum() # Ensures our Undum object is the same as Raconteur's
$ = require('jquery')
undum = require('undum-commonjs')
situation = require('raconteur/situation.js')
oneOf = require('raconteur/oneOf.js')
elements = require('raconteur/elements.js')
qualities = require('raconteur/qualities.js')
oneOf = require('raconteur/lib/oneOf.js')
elements = require('raconteur/lib/elements.js')
qualities = require('raconteur/lib/qualities.js')
a = elements.a
span = elements.span
@ -23,18 +22,55 @@ undum.game.version = "0.1"
situation 'start',
content: """
# Welcome to raconteur
![a storyteller](img/storyteller.jpg)
# Welcome to Raconteur
If you're seeing this, you've successfully installed the Raconteur game
scaffold. Get writing!
scaffold. Get writing!
Raconteur lives at a [Github Repository], where you can report issues or
send feedback.
[Github Repository]: https://github.com/sequitur/raconteur
"""
# ----------------------------------------------------------------------------
# Qualities
qualities
stats:
name: 'Statistics',
strength: qualities.integer('Strength', {priority: '001'}),
dexterity: qualities.integer('Dexterity', {priority: '002'}),
constitution: qualities.integer('Constitution', {priority: '003'}),
intelligence: qualities.integer('Intelligence', {priority: '004'}),
perception: qualities.integer('Perception', {priority: '005'}),
charisma: qualities.integer('Charisma', {priority: '006'})
possessions:
name: 'Possessions',
gold: qualities.integer('Gold'),
sword: qualities.wordScale('Sword', ['dull', 'sharp']),
shield: qualities.yesNo('Shield')
options:
extraClasses: ["possessions"]
#-----------------------------------------------------------------------------
# Initialise Undum
undum.game.init = (character, system) ->
# Add initialisation code here
character.qualities.strength = 10
character.qualities.dexterity = 12
character.qualities.constitution = 10
character.qualities.perception = 14
character.qualities.intelligence = 16
character.qualities.charisma = 8
character.qualities.gold = 100
character.qualities.sword = 1
character.qualities.shield = 1
# Get the party started when the DOM is ready.
$(undum.begin)
$(-> undum.begin())

@ -5,10 +5,10 @@
<meta charset="utf-8">
<!-- EDIT: Game title -->
<title>Raconteur Game Template</title>
<title>Raconteur Scaffold</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/undum.css">
<link rel="stylesheet" href="css/main.css">
<script type="text/javascript" src="game/bundle.js"></script>
</head>
<body>

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

@ -292,14 +292,15 @@ a {
transition: color 0.1s ease-in;
}
a.raw {
padding-right: 14px;
background: transparent url("../img/external_link.png") no-repeat right 4px;
// External link
border-bottom: 1px dashed @anchor-colour;
}
a:hover {
color: lighten(@anchor-colour, 10%);
}
img.float_right {
img {
.material_shadow();
float: right;
margin: 1.1em 0 1.1em 1.1em;
}

@ -10,9 +10,12 @@
"babelify": "^6.0.2",
"browser-sync": "^2.6.0",
"browserify": "^9.0.8",
"coffeeify": "^1.0.0",
"gulp": "^3.8.11",
"gulp-gzip": "^1.1.0",
"gulp-less": "^3.0.2",
"gulp-sourcemaps": "^1.5.1",
"gulp-minify-css": "^1.0.0",
"gulp-uglify": "^1.2.0",
"gulp-util": "^3.0.4",
"lodash": "^3.6.0",
"vinyl-buffer": "^1.0.0",

Loading…
Cancel
Save