Skip to content

Commit

Permalink
updated with js template
Browse files Browse the repository at this point in the history
  • Loading branch information
laurenfazah committed Mar 29, 2016
1 parent c1eae40 commit bbb7ef8
Show file tree
Hide file tree
Showing 24 changed files with 296 additions and 23 deletions.
12 changes: 12 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use strict';

// http://ericnish.io/blog/how-to-neatly-separate-grunt-files
// http://www.html5rocks.com/en/tutorials/tooling/supercharging-your-gruntfile/
// discuss how to break up gruntfiles

module.exports = function(grunt) {

require('time-grunt')(grunt);
require('load-grunt-config')(grunt);

};
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
3 changes: 3 additions & 0 deletions assets/scripts/example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

module.exports = true;
7 changes: 7 additions & 0 deletions assets/scripts/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

// user require with a reference to bundle the file and use it in this file
// var example = require('./example');

// use require without a reference to ensure a file is bundled
require('./example');
2 changes: 2 additions & 0 deletions assets/styles/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
$icon-font-path: '~bootstrap-sass/assets/fonts/bootstrap/';
@import '~bootstrap-sass/assets/stylesheets/bootstrap';
File renamed without changes.
23 changes: 0 additions & 23 deletions example/index.html

This file was deleted.

Empty file added favicon.ico
Empty file.
8 changes: 8 additions & 0 deletions grunt/aliases.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"default": ["nag"],
"build": ["webpack:build"],
"serve": ["webpack-dev-server:start"],
"nag": ["jshint", "jsonlint:all", "jscs:status"],
"reformat": ["jscs:write"],
"test": ["build", "jasmine"]
}
8 changes: 8 additions & 0 deletions grunt/jasmine.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"tests": {
"src": ["vendor.bundle.js", "bundle.js"],
"options": {
"specs": "specs.js"
}
}
}
21 changes: 21 additions & 0 deletions grunt/jscs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"options": {
"config": ".jscsrc",
"esnext": true,
"verbose": true
},

"status": {
"src": ["<%= paths.scripts.all %>"],
"options": {
"force": true
}
},

"write": {
"src": ["<%= paths.scripts.all %>"],
"options": {
"fix": true
}
}
}
8 changes: 8 additions & 0 deletions grunt/jshint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"all": {
"src": ["<%= paths.scripts.all %>"]
},
"options": {
"jshintrc": true
}
}
5 changes: 5 additions & 0 deletions grunt/jsonlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"all": {
"src": ["<%= paths.json.all %>"]
}
}
26 changes: 26 additions & 0 deletions grunt/paths.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"scripts": {
"all": [
"assets/scripts/**/*.js",
"spec/**/*.spec.js"
],
"src": [
"assets/scripts/**/*.js"
]
},

"grunt": {
"all": [
"Gruntfile.js",
"grunt/*.js"
]
},

"json": {
"all": [
"assets/scripts/**/*.json",
"spec/**/*.json",
"grunt/*.json"
]
}
}
22 changes: 22 additions & 0 deletions grunt/webpack-dev-server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';

let clone = require('clone');
// clone the webpack config to separate configuration of webpack and dev server
let webpackConfig = clone(require('./webpack').options);

// enable live reload without a script tag
webpackConfig.entry.vendor.unshift('webpack-dev-server/client?http://localhost:8080');

module.exports = {
options: {
webpack: webpackConfig
},

start: {
keepAlive: true,
webpack: {
devtool: 'source-map',
debug: 'true'
}
}
};
79 changes: 79 additions & 0 deletions grunt/webpack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
'use strict';

let webpack = require('webpack');
let path = require('path');

module.exports = {
options: {
entry: {
bundle: './index.js',
specs: './spec/_all.js',
vendor: ['jquery', 'bootstrap-sass'],
},

output: {
path: './',
filename: '[name].js'
},

plugins: [
new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.bundle.js'),
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
"window.jQuery": "jquery"
})
],

module: {
loaders: [
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel',
query: {
presets: ['es2015']
}
},
{
test: /\.css/,
loader: 'style!css',
includePaths: [path.resolve(__dirname, "./node_modules")]
},
{
test: /\.scss/,
loader: 'style!css!sass',
includePaths: [path.resolve(__dirname, "./node_modules")]
},
{
test: /\.woff[\d]?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: "url-loader?limit=10000&mimetype=application/font-woff"
},
{
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: "file-loader"
},
{
test: /\.(hbs|handlebars)$/,
loader: 'handlebars-loader'
},
{
test: /\.html\.(hbs|handlebars)$/,
loader: 'handlebars-loader!html'
}
]
},

stats: {
colors: true,
modules: true,
reasons: true
}
},

build: {
failOnError: true,
watch: false,
keepalive: false
}
};
24 changes: 24 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html>
<head>
<title>Example</title>

<script src="vendor.bundle.js" type="text/javascript" charset="utf-8" defer></script>
<script src="bundle.js" type="text/javascript" charset="utf-8" defer></script>
</head>
<body class="container-fluid">
<div class="half">
<p>I'm a box!</p>
</div>
<div class="half">
<p>I'm a box!</p>
</div>
<div class="half">
<p>I'm a box!</p>
</div>
<div class="full">
<p>I'm also a box!</p>
<p>Just a little different from those others.</p>
</div>
</body>
</html>
16 changes: 16 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict';

// user require with a reference to bundle the file and use it in this file
// var example = require('./example');

// load manifests
// scripts
require('./assets/scripts/index.js');

// styles
require('./assets/styles/index.scss');
require('./assets/styles/style.css');

// attach jQuery globally
require('expose?$!jquery');
require('expose?jQuery!jquery');
40 changes: 40 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "ga-wdi-boston-js-template",
"version": "0.0.2",
"private": true,
"license": "MIT",
"dependencies": {
"jquery": "^2.2.2"
},
"devDependencies": {
"babel-core": "^6.7.4",
"babel-loader": "^6.2.4",
"babel-preset-es2015": "^6.6.0",
"bootstrap-sass": "^3.3.6",
"clone": "^1.0.2",
"css-loader": "^0.23.1",
"expose-loader": "^0.7.1",
"file-loader": "^0.8.5",
"grunt": "^0.4.5",
"grunt-concurrent": "^2.2.1",
"grunt-contrib-jasmine": "^1.0.0",
"grunt-contrib-jshint": "^1.0.0",
"grunt-jscs": "^2.8.0",
"grunt-jsonlint": "^1.0.7",
"grunt-nodemon": "^0.4.1",
"grunt-open": "^0.2.3",
"grunt-webpack": "^1.0.11",
"handlebars": "^4.0.5",
"handlebars-loader": "^1.2.0",
"html-loader": "^0.4.3",
"load-grunt-config": "^0.19.1",
"node-libs-browser": "^1.0.0",
"node-sass": "^3.4.2",
"sass-loader": "^3.2.0",
"style-loader": "^0.13.1",
"time-grunt": "^1.3.0",
"url-loader": "^0.5.7",
"webpack": "^1.12.14",
"webpack-dev-server": "^1.14.1"
}
}
6 changes: 6 additions & 0 deletions spec/_all.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'use strict';

// Load all specs so webpack can find them. Think of this as an automatic
// manifest for bundling specs.
var req = require.context('./', true, /spec\.js$/);
req.keys().forEach(req);
9 changes: 9 additions & 0 deletions spec/example.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

var example = require('../assets/scripts/example');

describe('Example', function () {
it('is true', function () {
expect(example).toBe(true);
});
});

0 comments on commit bbb7ef8

Please sign in to comment.