ng-class-list-extractor

0.2.1 • Public • Published

Angular Class List Extractor

Determine what CSS classes an Angular Template or Component uses

Purpose

The tl;dr is this package was written for compatibility with TailwindCSS, specifically purging unused styles

This package has 0 additional dependencies aside from Angular's dependencies - There are 2 peer dependencies, Typescript and @angular/compiler which are used to create an AST of the component / template. Both peer dependencies are required to compile Angular.

Usage

// Example file: tailwind.config.js - compatible w/ Tailwind 1.x
const {extractClassesFromTemplate, extractClassesFromComponent} = require('ng-class-list-extractor');

module.exports = {
	purge: {
		// This is a liberal glob - it might include tests or modules.
		// You can probably get away with limiting ts files to `**/*.component.ts`
		content: ['./relative/path/to/app/**/*.html', './relative/path/to/app/**/*.ts'],
		options: {
			extractors: [{
				// Returns a list of classes used in a html template
				extractor: extractClassesFromTemplate,
				extensions: ['html']
			}, {
				// Returns a list of classes used in an inline component template
				extractor: extractClassesFromComponent,
				extensions: ['ts']
			}]
		}
	},
	theme: {
		extend: {},
	},
	variants: {},
	plugins: [],
};

Package Sidebar

Install

npm i ng-class-list-extractor

Weekly Downloads

1

Version

0.2.1

License

MIT

Unpacked Size

8.67 kB

Total Files

13

Last publish

Collaborators

  • vikaspotluri123