The local development server is a command line tool that sets up a test server on your computer, allowing you to see changes to your template before making them "live."
See the latest documentation at developers.squarespace.com/local-development.
To download the Squarespace Local Development Server, you need to have NPM installed on your computer. You should also ensure your NPM permissions are configured correctly.
Then:
npm install -g @squarespace/server
Prior to developing locally, you'll need a website set up with developer mode enabled. (See the Squarespace Quick Start guide.) Then clone your site into a folder using Git:
git clone https://site-name.squarespace.com/template.git
cd template
Then, to start Dev Server, run the following command:
squarespace-server https://site-name.squarespace.com
After starting squarespace-server, you will see the following screen:
Starting Development Server
_
/ / _
/ / / / \
/ / / / / | Squarespace Inc.
| / / / / / Local Development Environment
\ _ / / / /
/ /
-
Version 0.1.00
Listening on port 9000
The start-up message displays both the version of squarespace-server, and the port on which the server is running.
Now you can open your browser to your site by typing in the url http://localhost:9000
. Any changes you make to your local template files will be visible when you refresh your browser.
You can view all the options with the command:
squarespace-server --help
Here's a list of some of the more useful options:
squarespace-server URL [options]
Options:
-h --help Show this screen.
-d --directory=PATH Path to cloned template repository [default .].
-p --port=PORT Port that server listens on [default 9000].
-A --auto-reload Reloads page whenever file change is detected.
-T --trigger-reload Reloads page when manually triggered via API.
--auth Login to squarespace when starting server.
--faster-less Separately compiles and caches system less.
--verbose Verbose logging.
--version Show version.
If you have a site password, or your site is in trial mode, you'll need to log into your site via the dev server. You can do that with the following command:
squarespace-server https://site-name.squarespace.com --auth
The dev server can refresh the page when a change is detected. This can be performed either via the --auto-reload
or --trigger-reload
flags.
With --auto-reload
, a file watcher will monitor files in your template directory and refresh the page whenever a file changes. With --trigger-reload
,
the dev server will listen for a GET request to the /local-api/reload/trigger
endpoint. Whenever such a request is received, it will refresh the page.
This lets you configure a third-party file watching tool to trigger the reload.
File watching is an expensive task, so it's best to use trigger reloading when using a separate file-watcher to automatically transpile your template code. You can create a plugin for webpack or grunt to send the GET request when file changes are detected.
Both auto and trigger reloaders inject javascript into each page that listens for the reload events.
Normally all system and template less is compiled in a single pass into the main site.css
file. The --faster-less
option
instead creates two separate files for the template and system css. This speeds up rendering by only compiling the
template less per request, and caching system less. However some templates created by Squarespace contain less that depends on
the system less and will break with this option enabled. Bottom-line, if you are working on a template from scratch this option
will significantly speed up rendering.
If you have questions, or want to provide feedback on the Dev Server, please contact support and be sure to tell them that you're using the Squarespace Local Development Server.
Copyright 2016 Squarespace, Inc.
Use of the Squarespace Development Server software (“Dev Server”) is governed by the Developer Terms of Use, available at http://developers.squarespace.com/developer-terms-of-use/. Java SE Runtime Environment Software is bundled with the Dev Server. By using the Dev Server, you agree to the Oracle Binary Code License Agreement for the Java SE Platform Products and JavaFX, available at http://www.oracle.com/technetwork/java/javase/terms/license/index.html.