From 7df7fa7cc49589b1a02f170956d07520201514b7 Mon Sep 17 00:00:00 2001 From: Vit Brunner Date: Wed, 29 Oct 2014 13:36:05 +0100 Subject: [PATCH] Move script/style paths to Gruntfile --- Gruntfile.coffee | 72 +++++++++++++++++-------------- source/includes/scripts.html.jade | 14 ------ source/index.html.jade | 8 ++-- source/tests.html.jade | 3 +- 4 files changed, 46 insertions(+), 51 deletions(-) delete mode 100644 source/includes/scripts.html.jade diff --git a/Gruntfile.coffee b/Gruntfile.coffee index bf3957e..332de0f 100644 --- a/Gruntfile.coffee +++ b/Gruntfile.coffee @@ -1,18 +1,37 @@ module.exports = (grunt) -> + vars = { + scripts: [ + 'bower_components/lodash/dist/lodash.js' + 'bower_components/angular/angular.js' + 'bower_components/angular-route/angular-route.js' + 'bower_components/angular-sanitize/angular-sanitize.js' + 'bower_components/marked/lib/marked.js' + 'scripts/app.js' + 'scripts/services/fetch.js' + 'scripts/services/poems.js' + 'scripts/services/reader/_factory.js' + 'scripts/services/reader/markdown.js' + 'scripts/services/reader/json.js' + 'scripts/services/transformer.js' + 'scripts/controllers.js' + ] + styles: [ + 'bower_components/fontawesome/css/font-awesome.min.css' + 'bower_components/pure/pure-min.css' + 'styles/style.css' + ] + } + grunt.initConfig { pkg: grunt.file.readJSON 'package.json' - - var: { - source: 'source' - destination: 'build' - } + vars: vars coffee: { main: { expand: true - cwd: '<%= var.source %>' + cwd: 'source' src: '**/*.coffee' - dest: '<%= var.destination %>' + dest: 'build' ext: '.js' } } @@ -20,7 +39,7 @@ module.exports = (grunt) -> connect: { server: { options: { - base: '<%= var.destination %>' + base: 'build' } } } @@ -28,20 +47,16 @@ module.exports = (grunt) -> copy: { main: { expand: true - cwd: '<%= var.source %>' + cwd: 'source' src: 'tests/the_raven/*' - dest: '<%= var.destination %>' + dest: 'build' } } cssmin: { main: { files: { - 'build/min/styles.css': [ - 'build/bower_components/fontawesome/css/font-awesome.min.css' - 'build/bower_components/pure/pure-min.css' - 'build/styles/**/*.css' - ] + 'build/min/styles.css': ('build/' + style for style in vars.styles) } } } @@ -49,10 +64,13 @@ module.exports = (grunt) -> jade: { main: { expand: true - cwd: '<%= var.source %>' + cwd: 'source' src: '**/*.jade' - dest: '<%= var.destination %>' + dest: 'build' ext: '.html' + options: { + data: vars + } } } @@ -67,9 +85,9 @@ module.exports = (grunt) -> stylus: { main: { expand: true - cwd: '<%= var.source %>' + cwd: 'source' src: '**/*.styl' - dest: '<%= var.destination %>' + dest: 'build' ext: '.css' } } @@ -77,28 +95,18 @@ module.exports = (grunt) -> uglify: { main: { files: { - 'build/min/scripts.js': [ - 'build/bower_components/lodash/dist/lodash.js' - 'build/bower_components/angular/angular.js' - 'build/bower_components/angular-route/angular-route.js' - 'build/bower_components/angular-sanitize/angular-sanitize.js' - 'build/bower_components/marked/lib/marked.js' - 'build/scripts/**/*.js' - ] + 'build/min/scripts.js': ('build/' + script for script in vars.scripts) } } } watch: { main: { - files: '<%= var.source %>/**/*' + files: 'source' tasks: ['default', 'qunit'] } min: { - files: [ - '<%= var.destination %>/scripts/**/*.js' - '<%= var.destination %>/bower_components/**/*.js' - ] + files: ('build/' + script for script in vars.scripts) tasks: ['uglify'] } } diff --git a/source/includes/scripts.html.jade b/source/includes/scripts.html.jade deleted file mode 100644 index 5c1a997..0000000 --- a/source/includes/scripts.html.jade +++ /dev/null @@ -1,14 +0,0 @@ -// application scripts -script(src="bower_components/lodash/dist/lodash.js") -script(src="bower_components/angular/angular.js") -script(src="bower_components/angular-route/angular-route.js") -script(src="bower_components/angular-sanitize/angular-sanitize.js") -script(src="bower_components/marked/lib/marked.js") -script(src="scripts/app.js") -script(src="scripts/services/fetch.js") -script(src="scripts/services/poems.js") -script(src="scripts/services/reader/_factory.js") -script(src="scripts/services/reader/markdown.js") -script(src="scripts/services/reader/json.js") -script(src="scripts/services/transformer.js") -script(src="scripts/controllers.js") diff --git a/source/index.html.jade b/source/index.html.jade index d1de893..cb91e9f 100644 --- a/source/index.html.jade +++ b/source/index.html.jade @@ -4,9 +4,9 @@ html(ng-app="sideBySide") title Side By Side viewer meta(charset="utf-8") link(rel="stylesheet", type="text/css", href="//fonts.googleapis.com/css?family=Noticia+Text:400,700,400italic,700italic") - link(rel="stylesheet", type="text/css", href="bower_components/fontawesome/css/font-awesome.min.css") - link(rel="stylesheet", type="text/css", href="bower_components/pure/pure-min.css") - link(rel="stylesheet", type="text/css", href="styles/style.css") - include includes/scripts.html.jade + for style in styles + link(rel="stylesheet", type="text/css", href="#{style}") + for script in scripts + script(src="#{script}") include includes/body.html.jade diff --git a/source/tests.html.jade b/source/tests.html.jade index a65312a..4d873ac 100644 --- a/source/tests.html.jade +++ b/source/tests.html.jade @@ -4,7 +4,8 @@ html title Side By Side test suite meta(charset="utf-8") - include includes/scripts.html.jade + for script in scripts + script(src="#{script}") // test scripts link(rel="stylesheet", type="text/css", href="bower_components/qunit/qunit/qunit.css")