-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path.inline.js
56 lines (55 loc) · 1.51 KB
/
.inline.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
module.exports = {
shortcuts: [
{
name: 'pkg',
expand (file, ...args) {
return `../package.json|parse:${args.join()}`
}
},
{
name: 'css',
expand (file, css, indent = '0') {
return `css/${css}.css|cssmin|indent:${indent}|trim`
}
},
{
name: 'data',
expand (file, data, indent = '0') {
return `data/${data}.json|stringify:120|indent:${indent}|trim`
}
},
{
name: 'template',
expand (file, template, indent = '0') {
return `templates/${template}.html|indent:${indent}|trim`
}
}
],
transforms: [
{
name: 'indent',
transform (file, content, size = '2', indent = ' ') {
const indentString = (...args) => import('indent-string').then(({default: indentString}) => indentString(...args))
return indentString(content, parseInt(size, 10), { indent: indent })
}
},
{
name: 'cssmin',
transform (file, content) {
const CleanCSS = require('clean-css')
return new CleanCSS({ format: 'keep-breaks' }).minify(content).styles
}
},
{
name: 'stringify',
transform (file, content, maxLength = '80') {
const stringifyObject = (...args) => import('stringify-object').then(({default: stringifyObject}) => stringifyObject(...args))
return stringifyObject(JSON.parse(content), {
indent: ' ',
singleQuotes: true,
inlineCharacterLimit: parseInt(maxLength, 10)
})
}
}
]
}