1

Fixing stylesheet reference

This commit is contained in:
Alex Yatskov 2014-10-03 11:12:30 +09:00
parent 24454ed966
commit dfd4df9da2
3 changed files with 45 additions and 13 deletions

View File

@ -24,6 +24,8 @@
*/
'use strict';
var concat = require('gulp-concat');
var gulp = require('gulp');
var inject = require('gulp-inject');
@ -31,6 +33,7 @@ var jshint = require('gulp-jshint');
var mainBowerFiles = require('main-bower-files');
var minifyCss = require('gulp-minify-css');
var minifyHtml = require('gulp-minify-html');
var nodemon = require('gulp-nodemon');
var path = require('path');
var replace = require('gulp-replace');
var uglify = require('gulp-uglify');
@ -54,7 +57,7 @@ gulp.task('lint', function() {
});
gulp.task('images', function() {
return gulp.src('client/images').pipe(gulp.dest('client/dist/images'));
return gulp.src('client/images/*').pipe(gulp.dest('client/dist/images'));
});
gulp.task('fonts', function() {
@ -62,12 +65,13 @@ gulp.task('fonts', function() {
});
gulp.task('scripts', function() {
var scripts = ['client/scripts/*.js'].concat(getBowerFiles('.js'));
var scripts = getBowerFiles('.js').concat(['client/scripts/*.js']);
return gulp.src(scripts).pipe(concat('scripts.js')).pipe(uglify()).pipe(gulp.dest('client/dist'));
});
gulp.task('styles', function() {
var styles = ['client/styles/*.css'].concat(getBowerFiles('.css'));
var styles = getBowerFiles('.css').concat(['client/styles/*.css']);
console.log(styles);
return gulp.src(styles).pipe(replace('../fonts/', './fonts/')).pipe(concat('styles.css')).pipe(minifyCss()).pipe(gulp.dest('client/dist'));
});
@ -78,18 +82,21 @@ gulp.task('html_dev', function() {
return gulp.src(target).pipe(inject(sources, options)).pipe(gulp.dest('client'));
});
gulp.task('html_dist', ['scripts', 'styles'], function() {
gulp.task('html_dist', ['fonts', 'images', 'scripts', 'styles'], function() {
var sources = gulp.src(['client/dist/*.js', 'client/dist/*.css'], {read: false});
var options = {addRootSlash: false, ignorePath: 'client/dist'};
var target = 'client/html/index.html';
return gulp.src(target).pipe(inject(sources, options)).pipe(minifyHtml()).pipe(gulp.dest('client/dist'));
});
gulp.task('develop', function() {
var options = {script: 'server/server.js', ext: 'js', port: 8000};
gulp.task('dev', ['lint', 'html_dev'], function() {
var options = {script: 'server/server.js', ext: 'js', port: 8000, args: ['client']};
return nodemon(options).on('change', ['lint']);
});
gulp.task('dev', ['lint', 'html_dev']);
gulp.task('dist', ['lint', 'fonts', 'images', 'scripts', 'styles', 'html_dist']);
gulp.task('server', ['lint', 'develop']);
gulp.task('dist', ['html_dist'], function() {
var options = {script: 'server/server.js', ext: 'js', port: 8000, args: ['client/dist']};
return nodemon(options).on('change', ['lint']);
});
gulp.task('default', ['dev']);

View File

@ -1,5 +1,31 @@
#!/usr/bin/env node
/*
The MIT License (MIT)
Copyright (c) 2014 Alex Yatskov
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
'use strict';
var _ = require('underscore');
@ -7,8 +33,7 @@ var express = require('express');
var path = require('path');
var search = require('./search.js');
function main() {
function main(staticFiles) {
var app = express();
search.loadDb({
@ -41,10 +66,10 @@ function main() {
});
});
app.use(express.static(path.join(__dirname, '../client')));
app.use(express.static(path.join(__dirname, '..', staticFiles)));
app.listen(3000);
}
if (require.main === module) {
main();
main(process.argv[2] || 'client');
}