Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/uniho/minify-template-literal
https://github.com/uniho/minify-template-literal
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/uniho/minify-template-literal
- Owner: uniho
- License: mit
- Created: 2024-07-08T04:51:32.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-08-05T01:55:24.000Z (5 months ago)
- Last Synced: 2024-11-07T06:47:47.348Z (2 months ago)
- Language: JavaScript
- Size: 25.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# minify-template-literal
Minify the Template Literals with like Emotion, developit/htm, ...
[Emotion](https://emotion.sh/docs/introduction) is a library designed for writing css styles with JavaScript.
[developit/htm](https://github.com/developit/htm) is JSX-like syntax in plain JavaScript - no transpiler necessary.
## Installation
```bash
npm install --save-dev minify-template-literal
```## Basic Usage 1
hoge.js:
```js
import * as emotion from "https://esm.sh/@emotion/css@11";
import htm from "https://esm.sh/htm";
window.html = htm.bind(React.createElement);// Page Component for React
const Page = props => html`
{ throw new Error(1) }}>
TEST
`;//
const cssPage = emotion.css`
/* Some Comments */
color: skyblue;
background: black;
padding: 1rem;
`;```
Run minify-template-literal:
```bash
minify-template-literal hoge.js
```Output like that:
```js
import * as emotion from "https://esm.sh/@emotion/css@11";
import htm from "https://esm.sh/htm";
window.html = htm.bind(React.createElement);// Page Component for React
const Page = props => html` { throw new Error(1) }}>TEST`;//
const cssPage = emotion.css`color: skyblue; background: black; padding: 1rem;`;```
## Basic Usage 2
```bash
minify-template-literal hoge.js --outfile=out.js
```## Advanced Usage with esbuild
```bash
esbuild hoge.js --sourcemap --outfile=out.js
```And then, you can take a new source map.
```bash
minify-template-literal out.js --remap --outfile=out.js
```## Contribution
1. Fork it
1. Create your feature branch
1. Commit your changes
1. Push to the branch
1. Create new Pull Request## License
MIT