Git Product home page Git Product logo

notlmn / rollup-plugin-minify-tagged-css-template Goto Github PK

View Code? Open in Web Editor NEW
8.0 3.0 0.0 9 KB

Plugin to minify CSS content of tagged template string literals, aka. template strings aka. template literals.

Home Page: https://npmjs.com/package/rollup-plugin-minify-tagged-css-template

License: MIT License

JavaScript 100.00%
rollup rollup-plugin template-string template-literal tagged-template-string-literal css minify-css

rollup-plugin-minify-tagged-css-template's Introduction

rollup-plugin-minify-tagged-css-template

Plugin to minify CSS content of tagged template string literals, aka. template strings aka. template literals.

npm

Usage

// rollup.config.js
import minifyTaggedCSSTemplate from 'rollup-plugin-minify-tagged-css-template';

export default {
	input: 'test/index.js',
	plugins: [
		minifyTaggedCSSTemplate({ tags: ['css'] })
	],
	output: {
		file: 'build/index.js'
	},
};

Note: This plugin does not use AST based minification of CSS, because the content it receives is only partial.

Instead we aim to minify CSS with Regex based whitespace removal, and no optimization (deduping selectors, declaration, etc).

API

tags: string[] = ['css']

Refers to the tag names that are to be handled. Only static content of the template content is processed, any child template expressions are left unchanged. Refer to example below.

Example: tags: ['handleCSS'] would target the following template literal.

// component.js
const decl = 'color: red;';
const result = handleCSS`
	:host {
        display: block;
        ${decl}
	}
`;

// output
const result = handleCSS`:host{display:block;${decl}}`;

parserOptions: object

Config options to pass to the Babel parser.

Babel Parser options may be needed depending on how your project is structured. See Babel parser options for all available options.

Example:

// rollup.js
	// ...
	plugins: [
		transformTaggedTemplate({
			parserOptions: {
				sourceType: "module", // treat files as ES6 modules
				plugins: [
					"syntax-dynamic-import", // handle dynamic imports
					[
						"decorators", // use decorators proposal plugin
						{ decoratorsBeforeExport: true }
					]
				]
			}
		})
	],
	// ...

Related

License

MIT © Laxman Damera

rollup-plugin-minify-tagged-css-template's People

Contributors

notlmn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

rollup-plugin-minify-tagged-css-template's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.