Total Pageviews

Thursday 2 April 2020

静态网站生成器assemble

static site generator, an alternative to Jekyll for gh-pages and more! Gulp- and grunt-friendly. 

NPM version NPM monthly downloads Build Status Gitter
Looking for the grunt plugin? Please visit grunt-assemble.
(Note that the current website assemble.io, is for grunt-assemble. Thanks for your patience while we work on updating the site with documentation for the latest assemble).

Overview

(Click the following sections to expand them)
Table of contents
What is Assemble?
Who uses assemble?
Why should I use assemble?
What can I do with Assemble?
Rapid development toolkit
Features

Quickstart

Installing assemble

Add assemble your project's devDependencies using npm:
$ npm install -D assemble
You should now be able to run assemble directly (using node assemblefile.js etc) or using npm scripts. For example, add the following to package.json:
{
  "scripts": {
    "build": "assemble"
  }
}
Then run
$ npm run build

Installing assemble's CLI

You can also assemble's CLI globally, which adds the assemble command to your system path, allowing it to be run from any directory.
$ npm install --global assemble
Note that even if assemble is installed globally, it's good practice to install it locally in every project to ensure that your projects are protected against any potentially breaking changes that might occur in assemble between development cycles.

assemblefile.js

To use assemble's CLI, you'll need to add an assemblefile.js to your project. The fastest way to do this is to run the following command:
$ assemble
If no assemblefile.js exists in the current project, assemble will ask if you want to add one. If you answer yes, assemble will then generate a basic assembfile.js for you.

CLI

Run assemble from the command line.
$ assemble <tasks> [options]

Running tasks

Specify one or more space-separated tasks to run.
Examples
Run task foo
$ assemble foo
Run tasks foo and bar
$ assemble foo bar

Specifying options

Non-task options are prefixed with --.
Examples
Set the --cwd to run an assemblefile.js in a different directory:
$ assemble --cwd=docs
Emit views as they're loaded and log them to stderr:
$ assemble --emit=view
See more [command line options](#command line options)

Object expansion

Object-paths may be specified using dot-notation for either the key or value in a command line argument.
Additionally, assemble uses expand-object (and some custom parsing) to make it easier to pass non-trivial options and commands via command line. So all of the following formats are possible.
Examples
Boolean values:
$ assemble --foo 
# { foo: true }
Key-value pairs:
$ assemble --foo=bar
# { foo: 'bar' }
Nested booleans:
$ assemble --option=foo 
# {options: { foo: true }}
Nested key-value pairs:
$ assemble --option=foo:bar
# {options: { foo: 'bar' }}
Deeply nested key-value pairs:
$ assemble --option=foo.bar.baz:qux
# {options: foo: { bar: { baz: 'qux' }}}}
Or on the left-side of the =:
$ assemble --option.foo.bar.baz=qux
# {options: foo: { bar: { baz: 'qux' }}}}

Command line options

cwd

Change the cwd for the assemblefile.js to run, optionally specifying any tasks to run:
$ assemble <tasks> --cwd [directory]
Example
To run the scaffolds example in the examples/ directory, you would enter:
$ assemble --cwd examples/scaffolds
If successful, in the command line, you should see something like this:
screen shot 2016-01-09 at 1 35 52 pm

file

Specify the name of the config file for assemble's CLI to run, the default is assemblefile.js.
Example
$ assemble --file assemblefile.dev.js
frm https://github.com/assemble/assemble