├── .bowerrc ├── .gitignore ├── README.md ├── gulpfile.js ├── package.json ├── src ├── assets │ ├── apple-touch-icon-precomposed.png │ └── favicon.ico ├── data │ ├── data.js │ ├── index.json │ └── site.json ├── js │ ├── components │ │ ├── EmailInput.jsx │ │ ├── Hello.jsx │ │ ├── LoginForm.jsx │ │ ├── feature-list.jsx │ │ └── feature.jsx │ ├── main.jsx │ └── search.jsx ├── less │ ├── _one.less │ ├── _two.less │ ├── feature.less │ └── main.less └── templates │ ├── _layout.twig │ ├── index.twig │ └── modules │ └── _feature.twig └── webpack.config.js /.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "src/assets/vendor/" 3 | } 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | node_modules 3 | src/assets/vendor -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | gulp-react-webpack-twig-boilerplate 2 | ================== 3 | 4 | Base repo for building static pages compiled using Twig.js (ported from PHP Twig), with static asset compilation, and React JSX compiling and bundling with Webpack. -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | var gulp = require('gulp'); 2 | var data = require('gulp-data'); 3 | var twig = require('gulp-twig-with-data'); 4 | var less = require('gulp-less'); 5 | var plumber = require('gulp-plumber'); 6 | var prettify = require('gulp-html-prettify'); 7 | var webpack = require("webpack"); 8 | var browserify = require('gulp-browserify'); 9 | var concat = require('gulp-concat'); 10 | var webpack = require('gulp-webpack'); 11 | 12 | var connect = require('gulp-connect'); 13 | var open = require("gulp-open"); 14 | var port = process.env.port || 3031; 15 | 16 | gulp.task('webpack', function() { 17 | return gulp.src('./src/js/*.jsx') 18 | .pipe(webpack(require('./webpack.config.js'))) 19 | .pipe(gulp.dest('dist/assets/js')); 20 | }); 21 | 22 | gulp.task('compile', function() { 23 | return gulp.src(['./src/templates/*.twig', '!**/templates/**/_*.twig']) 24 | .pipe(plumber()) 25 | .pipe(data(require('./src/data/data.js'))) 26 | .pipe(twig()) 27 | .pipe(prettify({ 28 | indent_char: ' ', 29 | indent_size: 2 30 | })) 31 | .pipe(gulp.dest('./dist')); 32 | }); 33 | 34 | gulp.task('less', function() { 35 | return gulp.src(['./src/less/*.less', '!./src/less/_*.less']) 36 | .pipe(plumber()) 37 | .pipe(less()) 38 | .pipe(gulp.dest('./dist/assets/css')) 39 | }); 40 | 41 | gulp.task('assets', function() { 42 | return gulp.src('./src/assets/**/*') 43 | .pipe(plumber()) 44 | .pipe(gulp.dest('./dist/assets/')); 45 | }); 46 | 47 | gulp.task('open', function() { 48 | gulp.src('./dist/index.html') 49 | .pipe(open('', { 50 | url: 'http://localhost:' + port, 51 | })); 52 | }); 53 | 54 | // live reload server 55 | gulp.task('connect', function() { 56 | connect.server({ 57 | root: 'dist', 58 | port: port, 59 | livereload: true 60 | }); 61 | }); 62 | 63 | // live reload css 64 | gulp.task('reload:css', function() { 65 | gulp.src('./dist/assets/**/*.css') 66 | .pipe(connect.reload()); 67 | }); 68 | 69 | // live reload js 70 | gulp.task('reload:js', function() { 71 | gulp.src('./dist/assets/**/*.js') 72 | .pipe(connect.reload()); 73 | }); 74 | 75 | // live reload html 76 | gulp.task('reload:html', function() { 77 | gulp.src('./dist/*.html') 78 | .pipe(connect.reload()); 79 | }); 80 | 81 | // watch files for live reload 82 | gulp.task('watch', function() { 83 | gulp.watch('./dist/assets/**/*.css', ['reload:css']); 84 | gulp.watch('./dist/assets/**/*.js', ['reload:js']); 85 | gulp.watch('./dist/*.html', ['reload:html']); 86 | gulp.watch('./src/less/*.less', ['less']); 87 | gulp.watch(['./src/**/*.twig', './src/**/*.json'], ['compile']); 88 | gulp.watch('./src/js/**/*.jsx', ['webpack']); 89 | }); 90 | 91 | gulp.task('build', [ 92 | 'less', 93 | 'assets', 94 | 'compile', 95 | 'webpack' 96 | ]); 97 | 98 | gulp.task('serve', [ 99 | 'build', 100 | 'connect', 101 | 'open', 102 | 'watch' 103 | ]); 104 | 105 | gulp.task('default', ['build']); 106 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "landingpage-static", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "https://github.com/colynb/landingpage-static.git" 12 | }, 13 | "author": "", 14 | "license": "ISC", 15 | "bugs": { 16 | "url": "https://github.com/colynb/landingpage-static/issues" 17 | }, 18 | "homepage": "https://github.com/colynb/landingpage-static", 19 | "dependencies": { 20 | "gulp": "^3.8.10", 21 | "gulp-twig-with-data": "0.0.1" 22 | }, 23 | "devDependencies": { 24 | "gulp-browserify": "^0.5.1", 25 | "gulp-concat": "^2.4.3", 26 | "gulp-connect": "^2.2.0", 27 | "gulp-data": "^1.1.1", 28 | "gulp-html-prettify": "0.0.1", 29 | "gulp-less": "^2.0.1", 30 | "gulp-open": "^0.3.1", 31 | "gulp-plumber": "^0.6.6", 32 | "gulp-util": "^3.0.2", 33 | "gulp-webpack": "^1.1.2", 34 | "jsx-loader": "^0.12.2", 35 | "lodash": "^2.4.1", 36 | "react": "^0.12.2", 37 | "rimraf": "^2.2.8", 38 | "webpack": "^1.4.15" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/assets/apple-touch-icon-precomposed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/colynb/gulp-react-webpack-twig-boilerplate/716e61032025b792b5cfe056f26eadb7d2e3e8e6/src/assets/apple-touch-icon-precomposed.png -------------------------------------------------------------------------------- /src/assets/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/colynb/gulp-react-webpack-twig-boilerplate/716e61032025b792b5cfe056f26eadb7d2e3e8e6/src/assets/favicon.ico -------------------------------------------------------------------------------- /src/data/data.js: -------------------------------------------------------------------------------- 1 | var _ = require('lodash'); 2 | var path = require('path'); 3 | var fs = require('fs'); 4 | 5 | module.exports = function(file) { 6 | var pagePath = path.join(__dirname, path.basename(file.path, '.twig')) 7 | return _.assign( 8 | JSON.parse(fs.readFileSync(pagePath + '.json')), 9 | JSON.parse(fs.readFileSync(path.join(__dirname, 'site.json')))); 10 | } 11 | -------------------------------------------------------------------------------- /src/data/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "heading": "Hello, Landing Page Boilerplate!", 3 | "subhead": "This is a template for a simple marketing or informational website. It includes a large callout called a jumbotron and three supporting pieces of content. Use it as a starting point to create something more unique." 4 | } 5 | -------------------------------------------------------------------------------- /src/data/site.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Colyn's Landing Page Boilerplate" 3 | } 4 | -------------------------------------------------------------------------------- /src/js/components/EmailInput.jsx: -------------------------------------------------------------------------------- 1 | /** @jsx React.DOM */ 2 | 3 | var React = require('react'); 4 | 5 | var EmailInput = React.createClass({ 6 | 7 | render: function() { 8 | return ( 9 | 10 | ); 11 | } 12 | 13 | }); 14 | 15 | module.exports = EmailInput; -------------------------------------------------------------------------------- /src/js/components/Hello.jsx: -------------------------------------------------------------------------------- 1 | /** @jsx React.DOM */ 2 | 3 | var React = require('react'); 4 | 5 | var Hello = React.createClass({ 6 | 7 | render: function() { 8 | return ( 9 |
Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.
10 | 11 |