coffee-ssr
v1.0.1
Published
CLI tool for handling with SSR for angular coffee projects
Downloads
7
Readme
Coffee-SSR CLI
A CLI tool to facilitate the setup, configuration, and cleanup of Server-Side Rendering (SSR) for your Angular projects.
Prerequisites
- Node.js: Version 18 or higher is required.
Note: It's recommended to download any stable version above 8.11.1 from Node.js official website.
Installing Dependencies
To set up your project dependencies, navigate to the root directory of your project and run:
npm install
This command installs all the necessary packages specified in your package.json
file.
Running the Project
Serving the Application
To serve the application and watch for changes, use the following command:
npm run serve
This command starts the development server, which serves your application and watches for changes in the source files. Whenever you make changes, the server will automatically reload.
Starting the Application
To run the application, use:
npm run start
This command starts your application using Node.js. Ensure that any necessary build steps have been completed beforehand.
Building the Application
To build the application for production, use:
npm run build
This command compiles your TypeScript code, bundles it, and outputs it to the dist
directory. It optimizes the build for performance and smaller bundle sizes.
Installing the CLI Tool Globally
To install your CLI tool globally, run:
npm install -g .
This command installs your package globally on your system, allowing you to use the coffee-ssr
command from anywhere.
Linking the Project for Development
Alternatively, for development purposes, you can link your project by running:
npm link
This command creates a symbolic link to your project folder in the global node_modules
directory. It allows you to use the coffee-ssr
command locally without installing it globally.
CLI Usage
Command Overview
After installing your CLI tool, you can use the following commands:
generate routes
init
clean
generate routes
Command
This command extracts all routes from Angular routing modules within a specified directory.
Options
-d, --dir <directory>
:
Specifies the base directory to search for routing files.
Default:src/app/components/public
Example
To generate routes from a custom directory:
coffee-ssr generate routes --dir src/app/custom-directory
init
Command
This command initializes your Angular project for use with coffee-ssr
.
Example
To initialize the project:
coffee-ssr init
This will create the necessary files (coffee-ssr.ts
) and update your project configurations (like angular.json
and package.json
) to enable SSR with coffee-ssr
.
clean
Command
The clean
command scans and cleans your project files to ensure compatibility with SSR. It performs the following actions:
Cleans Angular Modules:
- Removes any import statements for
AngularSvgIconModule
from all Angular modules. - Replaces any usage of
AngularSvgIconModule
withCoffeeSvgIconModule
.
- Removes any import statements for
Cleans HTML Files:
- Replaces all
<svg-icon>
tags with<ngx-coffee-svg-icon>
.
- Replaces all
Cleans Stylesheets:
- Replaces any usage of
.svg-icon
with.ngx-coffee-svg-icon
in all.scss
and.css
files.
- Replaces any usage of
Example
To clean your project for SSR compatibility:
coffee-ssr clean
This will automatically clean and modify the files to be SSR-compatible.