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.
npm install -g @squarespace/server
Prior to developing locally, you'll need a website set up with developer mode enabled. (See the Squarespace Getting Started 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:
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:
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, a file watcher will monitor files in your template directory and refresh the page whenever a file changes. With
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.
Normally all system and template less is compiled in a single pass into the main
site.css file. The
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.