@cloudcannon/suite
Version:
A suite of gulp tools to manage static sites on CloudCannon
66 lines (61 loc) • 2.43 kB
Markdown
---
title: Setup
package: Dist
order_number: 2
subtasks:
- name: build
desc: Compiles HTML and CSS to be run at a baseurl
code: gulp dist:build
- name: serve
desc: Runs a local webserver on the `dest` folder
code: gulp dist:serve
- name: watch
desc: Watches the `src` folder and triggers builds
code: gulp dist:watch
- name: rewrite-html
desc: Clones HTML files from `src` to `dist` and rewrites attributes to include baseurl (`src`, `href`, `srcset` and `meta[http-equiv='refresh']`)
code: gulp dist:rewrite-html
- name: rewrite-css
desc: Clones CSS files from src to dist and rewrites urls to include baseurl
code: gulp dist:rewrite-css
- name: clone-assets
desc: Clones all other files from `src` to `dist`
code: gulp dist:clone-assets
- name: clean
desc: Removes all files from the `dist` folder
code: gulp dist:clean
---
To use this package, add `suite.dist(gulp)` to your Gulpfile. You can pass in an options object to configure the baseurl. See [Configuration](/dist/configuration) for more details.
```js
const gulp = require("gulp");
const suite = require("@cloudcannon/suite");
suite.dist(gulp, {
"dist": {
"baseurl":"p"
}
});
```
Running `gulp dist` prepends a baseurl to the entire site at `src`. HTML and CSS files are rewritten to fix references for the new folder structure. All files are cloned into the `dist` folder with the baseurl prepended. Once completed, a local webserver will be started on port 9000. Any changes to the `src` folder will trigger a rebuild of the contents.
```bash
$ gulp dist
[] Using gulpfile ./gulpfile.js
[] Starting 'dist'...
[] Starting 'dist:build'...
[] Starting 'dist:clean'...
[] Finished 'dist:clean' after 383 ms
[] Starting 'dist:rewrite-html'...
[] Starting 'dist:rewrite-css'...
[] Starting 'dist:clone-assets'...
[] Finished 'dist:rewrite-css' after 639 ms
[] Finished 'dist:rewrite-html' after 7.1 s
[] Finished 'dist:clone-assets' after 7.38 s
[] Finished 'dist:build' after 7.78 s
[] Starting 'dist:serve'...
[] Webserver started at http://localhost:9000
[] Finished 'dist:serve' after 18 ms
[] Starting 'dist:watch'...
[] Finished 'dist:watch' after 6.66 s
[] Finished 'dist' after 14 s
```
{% include package-subtasks.md %}