How to Run a Pure CSS Website Locally

Jul 3, 2022 | Programming

Creating a pure and seamless experience for users is what every developer strives for, and with the Pure CSS website, you can do just that! This blog will guide you step-by-step on how to run the website locally, ensuring easy accessibility and testing of features in real time.

Prerequisites

Before we jump into the installation and running of the Pure CSS website, ensure that you have the following prerequisites installed on your machine:

  • Node.js: Make sure to have Node.js installed, as this site uses Express.js.
  • npm: The package manager that comes with Node.js.

Getting Started

Follow these steps to get the Pure CSS website running on your local machine:

1. Clone the Repository

First, make sure you clone the Pure CSS website repository onto your local machine. Use the following command:

shell$ git clone https://github.com/pure-css/pure-site.git

2. Install Dependencies

Navigate to the project directory and install the necessary dependencies using npm:

shell$ cd pure-site
$ npm install

3. Start the Server

Now, you can start the server by running:

shell$ npm start

4. Run Health Checks

To ensure everything is running smoothly, you can perform health checks with Grunt:

shell$ grunt health.check

By default, this command uses the local instance running on port 5000. You have the option to specify a remote host if necessary:

shell$ grunt health.check --host=foo

Auto-Building of Browser Assets

One of the spectacular features of the Pure CSS website is its integrated build process using Broccoli. When running in development mode, Broccoli will monitor changes in the public directory and rebuild assets automatically. This functionality significantly simplifies the workflow related to browser-side features, saving you from manually restarting the server every time!

Serving Pure Locally

This website “dogfoods” Pure, meaning it’s an excellent way to test out any local changes you make to the Pure framework. To do this:

  • Navigate to the local Pure project directory.
  • Build using Grunt:
  • shell$ cd pure
    $ grunt
  • Create a global link with npm:
  • shell$ npm link
  • Now, move back to the Pure site project directory and link Pure:
  • shell$ cd ..
    $ cd pure-site
    $ npm link purecss
  • Finally, start the server with the –pure-local argument:
  • shell$ node server.js --pure-local

Note: You don’t have to run the linking and installation commands each time the server starts. Moreover, you can keep the server running while rebuilding Pure via Grunt, and see the changes in your browser after refreshing!

Running in Production

If you wish to run the site in production mode, ensure you first build the site using Grunt, and set the NODE_ENV environment variable:

shell$ grunt
$ NODE_ENV=production node server

License

This software is free to use under the Yahoo! Inc. BSD license. For full license text and copyright information, please refer to the LICENSE file.

Troubleshooting

If you encounter any issues while setting up the Pure CSS website, consider the following troubleshooting tips:

  • Ensure that Node.js and npm are installed correctly.
  • If you experience issues with port conflicts, verify that no other applications are using port 5000.
  • Check the console for any errors during the npm install process and rectify them as needed.
  • If you are running health checks against a remote host, ensure that the host address is reachable.

For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

Conclusion

By following the steps outlined in this guide, you can easily set up and run the Pure CSS website locally, making it a breeze to develop and test features in real time. At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox