2.0.1 • Published 8 years ago

guh v2.0.1

Weekly downloads
5
License
MIT
Repository
github
Last release
8 years ago

guh

npm version node version license

npm install -g guh
guh new

# cd into your new project and 'npm install', then 'guh build'
# use 'npm start' to run the app!

A template project and generator for full-stack TypeScript and Sass (SCSS) projects.

guh has the following goals:

  • Flexible configuration
  • Intuitive organization
  • Isolated builds
  • Automated deployments

These goals are accomplished with the following technologies:

  • TypeScript
  • Browserify
  • Sass (libsass)
  • PostCSS
  • Gulp
  • Docker (production)

Sass compiled via guh has globbing and single-import capability via PostCSS plugins.

See CHANGES for a complete changelog.

Requirements

  • node >=5.0

Generator CLI

Run guh new (like GNU) to generate a new guh-enabled project. A wizard will guide you through your setup.

Upgrading

Upgrading the guh-core package should be safe within SemVer bounds. Configurations will stay valid across minor version upgrades, but are not guaranteed across major version changes.

Usage

The build system can be run in its default configuration with guh build (or gulp). This loads the default preset defined in the configuration.

Flags can be set with the following syntax:

  • --flag: enable
  • --flag=yes, --flag=true: enable
  • --flag=no, --flag=false: disable

Flags

flagdefaultfunction
watchnoWatch the filesystem for changes
sourcemapsyesBuild sourcemaps for client code
minifynoMinify client code
notifynoNotify on build completion
browsersyncnoRun client via Browsersync
oncenoTurns off Browserync and file watching if set.
drynoTurns off output to the filesystem.

Default values are used if the configuration does not specify a value and value was given on the CLI.

Parameters

parameterfunction
--out=PATHOutputs result into PATH
--preset=PRESETSets build preset to PRESET
--only=MODULE[,MODULE2,...]Build only these modules
--except=MODULE[,MODULE2,...]Don't build these modules
--gray=MODULE[,MODULE2,...]Build these modules even if disabled

Presets

Presets set default values for many of these flags and parameters.

Debug

keyvalue
out./debug
watchyes
sourcemapsyes
minifyno
browsersyncyes

Production

keyvalue
out./production
watchno
sourcemapsno
minifyyes
browsersyncyes

The default production preset also adds an extra pipeline, copying package.json and Dockerfile to the build directory.

Examples

To build a production build:

guh build --preset=production

To build just stylesheets once in debug mode:

guh build --watch=no --only=stylesheets

To build a debug build without sourcemaps, but with minification to ./derp, try

guh build --sourcemaps=no --minify --out=derp

Files

In debug mode (the default), the output is contained in debug. In production mode, it can be found in production.

Configuration

The primary configuration is located inside build.conf.js. guh will also load build.user.conf.js if it exists, which will take precedence over the primary configuration.

It's recommended that the user config file stays out of version control. It should be based on the following code to patch the primary config:

"use strict";

let conf = require("./build.conf");

// modify conf

module.exports = conf;

Top-Level Configuration

The configuration object has a number of fields that affect compilation globally.

keyvalue
browsersyncA configuration object passed directly to Browsersync. Omit the object to turn off Browsersync.
presetThe default preset name to use.
presetsA hashmap of defined presets.
pipelinesThe list of pipelines to apply when building.

Pipelines

All pipelines are plain JS objects with some specific keys.

Every pipeline may specify these keys:

keyvalue
type(required) The type of pipeline to use.
idAn optional unique ID for this pipeline. Duplicates are removed.
tagsA list of tags to group this pipeline with others.
nameA friendly name for the pipeline.
input(required) This pipeline's input files.
outputThis pipeline's output location.
drySet to true to disable writing to the filesystem.
disabledWhether this pipeline is turned off by default. Defaults to false.
configExtra parameters specific to the pipeline.
callbackA callback to call when a file finishes building. Parameters are (pipeline, filePath, fileContents)
watchPathsA list of glob-enabled paths to watch for file changes. Works on all pipeline types except browser (guh-core 1.5.0+)

By specifying the same id in two pipelines, values can be overridden in more specific contexts. Defining a pipeline with id of "test" in the base configuration, then defining another pipeline with the same id in a preset will allow the preset to override values.

For example:

{
	presets: {
		production: {
			out: "production",
			pipelines: [
				{
					id: "test",
					disabled: true
				}
			]
		}
	},
	pipelines: [
		{
			id: "test",
			name: "Test the Things!",
			type: "static",
			input: "src",
			output: ""
		}
	]
}

Here, when running in most any preset, the test pipeline will copy some files around. When the production preset is activated, the pipeline will be disabled.

type server

The server pipeline compiles TypeScript files recursively, targeted at server environments.

keyvalue
extraEntriesExtra entries to pass to the TS compiler, usually typings (.d.ts) files
typingsOutputThe output directory for typings files. Not outputted if omitted.
typingsOutputTypeThe type of typings to output. "ambient" bundles into a single file, "module" creates typings suitable for bundling in an npm module. Defaults to ambient.
moduleNameThe name of the module to export from the typings files. Only used in "ambient" typings output.
moduleEntryPointThe file marked as the entry point of the module. Only used in "ambient" typings output.

The config parameter is an object with the following keys:

keyvalue
typescriptPassed directly to TypeScript
partialRebuildWhether to rebuild only changed files. Faster, but may miss some errors.

type browser

The browser pipeline compiles an entry point TypeScript file and its dependencies into a Browserify bundle.

keyvalue
extraEntriesExtra entries to pass to the TS compiler, usually typings (.d.ts) files

The config parameter is an object with the following keys:

keyvalue
typescriptPassed directly to gulp-typescript
browserifyPassed directly to Browserify

type styles

The styles pipeline compiles an entry point Sass file into a single CSS bundle.

The config parameter is an object with the following keys:

keyvalue
sassPassed directly to node-sass
sassyImportPassed directly to postcss-sassy-import
autoprefixerPassed directly to autoprefixer
stylelintPassed directly to stylelint

type static

The static pipeline copies files as-is and applies no changes to them.

keyvalue
renameRename the output to this file name. Only works if the input is a single file.

License

guh is available under the MIT license. See LICENSE for more details.

2.0.1

8 years ago

2.0.0

8 years ago

2.0.0-beta10

8 years ago

2.0.0-beta9

8 years ago

2.0.0-beta8

8 years ago

2.0.0-beta7

8 years ago

2.0.0-beta6

8 years ago

2.0.0-beta5

8 years ago

2.0.0-beta4

8 years ago

2.0.0-beta3

8 years ago

2.0.0-beta2

8 years ago

2.0.0-beta1

8 years ago

2.0.0-alpha13

8 years ago

2.0.0-alpha12

8 years ago

2.0.0-alpha11

8 years ago

2.0.0-alpha10

8 years ago

2.0.0-alpha9

8 years ago

2.0.0-alpha8

8 years ago

2.0.0-alpha7

8 years ago