- Fortawesome Free
- Npm Fortawesome
- Fortawesome Fontawesome Free
- Fontawesome Free 5
- Npm Fontawesome Free
- Install Fortawesome React
One of the constant requests I have as a freelancer programmer is constructing a landing page for a project/company/research project. Therefore, it is better to have an already starter template adopted as a base to iterate upon it quickly.My starter (https://github.com/wittyprogramming/tailwindcss-alpinejs-starter), is an opinionated template that has the following features:
- Tailwind CSS for styling
- Alpine.js for template/dynamic logic
- a simple build system that may help me scale up if the needs arise (for example, add scss for styles or Typescript)
There are 3 parts to using Font-Awesome in Angular Projects. Installation; Styling (CSS/SCSS) Usage in Angular; Installation. Install from NPM and save to your package.json.
Tailwind CSS is a highly customizable, low-level CSS framework gaining popularity lately. It is not opinionated as it gives you the building blocks for styling your components.
Unfortunately, tailwind requires a build system to take advantage of all its features. Furthermore, during deployment, the unused CSS must be removed because the style file becomes very large (>2Mb). The PostCSS and its plugins come to the rescue.
I must say that Alpine.js, which does not use a virtual DOM, has some tricked spots regarding the scope of nested components and their communication or the way nested loops are constructed, but for most cases - e.g., landing pages - is adequate. For more information, checkout out my post introducing Alpine.js.
Finally, we will use the gorgeous, simple, and versatile landing page design from the Creative Tim’s Tailwind Starter Kit for our starter template’s design. It way better for our productivity to have a well-formed, responsive design as a base.
Let’s initialize our starter:
The structure of the template is straightforward:
src/css/folder contains our template’s source styles with the file
main.cssas the entry point.
src/ts/folder contains our typescript code with the file
main.tsas the entry point.
assets/ folder contains the static assets - img, files to downloads, etc. Here, the output files from the CSS (CSS and web fonts) and js (js file) build system will be created.
Let’s begin by getting the
landing.html and the Landing Page starter kit’s assets folder. We don’t need the
vendor directory (contains fontawesome icons) as we will self-hosted it ourselves.
Then, install the required packages:
It is time to create a build system for the styles based on PostCSS, a modern plugin-based CSS parser. The
src/css/ folder contains our source CSS, which builds a minified clean version in the file
Next, install the dev dependencies:
- its cli version,
- and the plugins:
postcss-importfor using the import function in CSS,
@fullhuman/postcss-purgecssfor the purgings of the unused CSS styles,
postcss-copyfor copying assets referenced as web fonts , and, of course,
cssnanopackage for the minification.
The postcss.config.js format is straightforward. We define our plugins, and when we initiate the deployment build by using an environmental variable, we use the purge CSS and minification plugins.
package.json build scripts are:
cross-env is an npm package that sets environment variables in a cross-platform away.
Next step, the
esbuild is added.
esbuild does not have a watch function in its cli utility (see this issue). No worries, the chokidar-cli is an excellent cross-platform command-line utility to watch file system changes.
– UPDATE 14 Feb 2021 –
The above is not valid anymore. After version v0.8.38, the esbuild added a
-watch flag that makes the
chokidar-cli package unnecessary. Moreover, after the v0.8.45, the esbuild added the
--servedir= flag, allowing running a built-in web development server. The rest directions reflect that change. If you prefer the previous configuration with the
chokidar-cli package, please refer to a previous commit in the GitHub repository
I like to use Typescript, as the IntelliSense that provides is impressive and very helpful. I understand that Typescript is not everyone’s favorite, and it may complicate some things unnecessary. Hence, the following step is not required, but to acquire the Typescript’s Intellisense superpower, install the
typescript packages and initialize a
tsconfig.js in the
And in the
src/ts folder run the following command to initialize the
main.ts, import the
The package scripts are very straightforward:
watch-js command watches for any changes and creates a debug build of our code with a source map. The
debug-js command is the same as the
watch-js command, but it runs the esbuild built-in web development server. The
build-js command executes our deployment pipeline and outputs the minified code.
To run both commands, will use the concurrently npm package:
and add the stript:
Fortawesome Fontawesome Free
Finally, the deployment command runs the
build-css commands and copy the
assets folder to a
dist folder using the
copyfiles package. This
dist folder is the deployment folder.
Therefore, during the development (for the watch mode) use:
If you want a web development server alongside use :
For deployment, run:
Starter Github Repository
Fontawesome Free 5
You can use the provided starter template freely at https://github.com/wittyprogramming/tailwindcss-alpinejs-starter
Npm Fontawesome Free