Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chenjiahan/template-string-optimize-loader
template string optimize loader module for webpack
https://github.com/chenjiahan/template-string-optimize-loader
optimize template-string webpack
Last synced: 4 months ago
JSON representation
template string optimize loader module for webpack
- Host: GitHub
- URL: https://github.com/chenjiahan/template-string-optimize-loader
- Owner: chenjiahan
- License: mit
- Created: 2016-01-07T01:49:25.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2023-07-11T13:22:40.000Z (over 1 year ago)
- Last Synced: 2024-10-03T09:25:30.854Z (4 months ago)
- Topics: optimize, template-string, webpack
- Language: JavaScript
- Size: 425 KB
- Stars: 16
- Watchers: 3
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# template-string-optimize-loader
template string optimize loader module for webpack## Installation
npm i template-string-optimize-loader -D
## Usage``` javascript
module: {
rules: [
{
test: /\.js$/,
use: [
'template-string-optimize-loader',
'babel-loader'
]
}
]
}
```## Example
``` html
// ES6 template string HTML
const template = data => `
${data.title}
${data.date}
- Coffee
- Black hot drink
- Milk
-
- ${item}
${data.list.map((item) => `
`).join('')}
`;
```
``` javascript
// source => babel
var template = function template(data) {
return '\n \n \n
' + data.title + '
\n- \n
- Coffee \n
- Black hot drink \n
- Milk \n
- \n
- \n ' + data.list.map(function (item) {
- ' + item + ' \n ';
return '\n
}).join('') + '\n \n
};
```
``` javascript
// source => babel => template-string-optimize
var template = function template(data) {
return '
' + data.title + '
- Coffee
- Black hot drink
- Milk
- ' + data.list.map(function (item) {
- ' + item + ' ';
return '
}).join('') + '
};
```