coffee-ssr
v1.0.1
Published
CLI tool for handling with SSR for angular coffee projects
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 installThis 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 serveThis 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 startThis 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 buildThis 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 linkThis 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 routesinitclean
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-directoryinit Command
This command initializes your Angular project for use with coffee-ssr.
Example
To initialize the project:
coffee-ssr initThis 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
AngularSvgIconModulefrom all Angular modules. - Replaces any usage of
AngularSvgIconModulewithCoffeeSvgIconModule.
- 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-iconwith.ngx-coffee-svg-iconin all.scssand.cssfiles.
- Replaces any usage of
Example
To clean your project for SSR compatibility:
coffee-ssr cleanThis will automatically clean and modify the files to be SSR-compatible.
