@newlogic-digital/core 0.9.14 → 1.0.0-beta.3
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +15 -45
- package/index.js +262 -43
- package/package.json +13 -57
- package/LICENSE +0 -674
- package/modules/Core.js +0 -626
- package/modules/Emails.js +0 -110
- package/modules/Icons.js +0 -140
- package/modules/Scripts.js +0 -321
- package/modules/Serve.js +0 -124
- package/modules/Styles.js +0 -298
- package/modules/Templates.js +0 -477
- package/modules/Utils.js +0 -299
- package/modules/Watch.js +0 -75
- package/modules/tailwind/index.cjs +0 -84
- package/modules/tailwind/index.js +0 -75
- package/packages/gulp-clean-css/LICENSE +0 -20
- package/packages/gulp-clean-css/README.md +0 -79
- package/packages/gulp-clean-css/index.js +0 -66
- package/packages/gulp-clean-css/package.json +0 -68
- package/packages/gulp-twig2html/CHANGELOG.md +0 -77
- package/packages/gulp-twig2html/LICENSE +0 -22
- package/packages/gulp-twig2html/README.md +0 -112
- package/packages/gulp-twig2html/index.js +0 -30
- package/packages/gulp-twig2html/package.json +0 -47
- package/packages/postcss-inset/CHANGELOG.md +0 -5
- package/packages/postcss-inset/LICENSE.md +0 -106
- package/packages/postcss-inset/README.md +0 -121
- package/packages/postcss-inset/index.cjs.js +0 -49
- package/packages/postcss-inset/index.es.mjs +0 -47
- package/packages/postcss-inset/index.js +0 -47
- package/packages/postcss-inset/package.json +0 -58
- package/packages/twig-renderer/CHANGELOG.md +0 -66
- package/packages/twig-renderer/LICENSE +0 -22
- package/packages/twig-renderer/README.md +0 -93
- package/packages/twig-renderer/package.json +0 -49
- package/packages/twig-renderer/twig-renderer.js +0 -90
package/modules/Utils.js
DELETED
@@ -1,299 +0,0 @@
|
|
1
|
-
import fs from "fs";
|
2
|
-
import fse from "fs-extra";
|
3
|
-
import nodeCmd from "child_process";
|
4
|
-
import gulp from "gulp";
|
5
|
-
import postcssImport from "postcss-import";
|
6
|
-
import postcssNesting from "postcss-nesting";
|
7
|
-
import postcssCustomMedia from "postcss-custom-media";
|
8
|
-
import postcssCustomSelectors from "postcss-custom-selectors";
|
9
|
-
import tailwindcssNesting from "tailwindcss/nesting/index.js";
|
10
|
-
import {Config, Exists, Functions, root} from "./Core.js";
|
11
|
-
|
12
|
-
export class Utils {
|
13
|
-
cleanup() {
|
14
|
-
return new Promise(resolve => {
|
15
|
-
if (fs.existsSync(root + Config.paths.temp)) {
|
16
|
-
fse.emptyDirSync(root + Config.paths.temp);
|
17
|
-
fs.writeFileSync(root + Config.paths.temp + "/.gitkeep", "");
|
18
|
-
}
|
19
|
-
|
20
|
-
if (fs.existsSync(root + Config.paths.output.assets) && Config.paths.output.assets !== Config.paths.output.root) {
|
21
|
-
fse.removeSync(root + Config.paths.output.assets);
|
22
|
-
}
|
23
|
-
|
24
|
-
if (fs.existsSync(root + Config.paths.output.styles)) {
|
25
|
-
fse.removeSync(root + Config.paths.output.styles);
|
26
|
-
}
|
27
|
-
|
28
|
-
if (fs.existsSync(root + Config.paths.output.scripts)) {
|
29
|
-
fse.removeSync(root + Config.paths.output.scripts);
|
30
|
-
}
|
31
|
-
|
32
|
-
(function(){
|
33
|
-
if (fs.existsSync(`${root + Config.paths.input.templates}/`)) {
|
34
|
-
let pages = fs.readdirSync(`${root + Config.paths.input.templates}/`),
|
35
|
-
items = pages.length;
|
36
|
-
|
37
|
-
for (let i = 0; i < items; i++) {
|
38
|
-
if (fs.existsSync(`${root + Config.paths.output.root}/${pages[i]}`)) {
|
39
|
-
fs.unlinkSync(`${root + Config.paths.output.root}/${pages[i]}`);
|
40
|
-
} else if (fs.existsSync(`${root + Config.paths.output.root}/${pages[i].replace('.json', '.html')}`)) {
|
41
|
-
fs.unlinkSync(`${root + Config.paths.output.root}/${pages[i].replace('.json', '.html')}`);
|
42
|
-
}
|
43
|
-
}
|
44
|
-
}
|
45
|
-
})();
|
46
|
-
|
47
|
-
resolve()
|
48
|
-
});
|
49
|
-
}
|
50
|
-
importMap() {
|
51
|
-
return new Promise((resolve) => {
|
52
|
-
fs.readFile(`package.json`, 'utf8', (err, data) => {
|
53
|
-
let dependencies = JSON.parse(data)["dependencies"];
|
54
|
-
let cdn = Config.scripts.importMap.cdn;
|
55
|
-
let version = "";
|
56
|
-
let url;
|
57
|
-
let urlSub;
|
58
|
-
let imports = JSON.parse(data)["imports"];
|
59
|
-
let importMap = {
|
60
|
-
"imports": {}
|
61
|
-
};
|
62
|
-
|
63
|
-
if (typeof dependencies === "undefined") {
|
64
|
-
resolve();
|
65
|
-
return false;
|
66
|
-
}
|
67
|
-
|
68
|
-
if (cdn === "esm.sh") {
|
69
|
-
if (Config.scripts.importMap.version !== "") {
|
70
|
-
version = `${Config.scripts.importMap.version}/`
|
71
|
-
}
|
72
|
-
if (!Config.scripts.importMap.shortUrl) {
|
73
|
-
url = `https://cdn.esm.sh/${version}{DEPENDENCY}@{VERSION}/${Config.scripts.importMap.target}/{DEPENDENCY}.js`;
|
74
|
-
urlSub = `https://cdn.esm.sh/${version}{DEPENDENCY}@{VERSION}/${Config.scripts.importMap.target}/`;
|
75
|
-
} else {
|
76
|
-
url = `https://esm.sh/{DEPENDENCY}@{VERSION}`;
|
77
|
-
urlSub = "https://esm.sh/{DEPENDENCY}@{VERSION}/";
|
78
|
-
}
|
79
|
-
} else if (cdn === "esm.run") {
|
80
|
-
if (!Config.scripts.importMap.shortUrl) {
|
81
|
-
url = "https://cdn.jsdelivr.net/npm/{DEPENDENCY}@{VERSION}/+esm";
|
82
|
-
urlSub = "https://cdn.jsdelivr.net/npm/{DEPENDENCY}@{VERSION}/";
|
83
|
-
} else {
|
84
|
-
url = `https://esm.run/{DEPENDENCY}@{VERSION}`;
|
85
|
-
urlSub = "https://esm.run/{DEPENDENCY}@{VERSION}/";
|
86
|
-
}
|
87
|
-
} else if (cdn === "jspm.dev") {
|
88
|
-
url = `https://jspm.dev/{DEPENDENCY}@{VERSION}`;
|
89
|
-
urlSub = "https://jspm.dev/{DEPENDENCY}@{VERSION}/";
|
90
|
-
} else if (cdn === "skypack.dev") {
|
91
|
-
url = `https://cdn.skypack.dev/{DEPENDENCY}@{VERSION}`;
|
92
|
-
urlSub = "https://cdn.skypack.dev/{DEPENDENCY}@{VERSION}/";
|
93
|
-
}
|
94
|
-
|
95
|
-
Object.keys(dependencies).forEach((dependency) => {
|
96
|
-
if (dependency.includes("/") && cdn === "esm.sh") {
|
97
|
-
importMap.imports[dependency] = url.replace("{DEPENDENCY}", dependency).replace("{VERSION}", dependencies[dependency].replace("^","")).replace("{DEPENDENCY}", dependency.split("/")[1])
|
98
|
-
} else {
|
99
|
-
importMap.imports[dependency] = url.replace(new RegExp("{DEPENDENCY}", 'g'), dependency).replace("{VERSION}", dependencies[dependency].replace("^",""))
|
100
|
-
}
|
101
|
-
|
102
|
-
if (dependency.match(Config.scripts.importMap.trailingSlashes)) {
|
103
|
-
importMap.imports[`${dependency}/`] = urlSub.replace("{DEPENDENCY}", dependency).replace("{VERSION}", dependencies[dependency].replace("^",""))
|
104
|
-
}
|
105
|
-
});
|
106
|
-
|
107
|
-
if (typeof imports !== "undefined") {
|
108
|
-
importMap = {
|
109
|
-
"imports": Object.assign(importMap.imports, imports)
|
110
|
-
};
|
111
|
-
}
|
112
|
-
|
113
|
-
if (!fs.existsSync(root + Config.paths.output.root)){
|
114
|
-
fs.mkdirSync(root + Config.paths.output.root);
|
115
|
-
}
|
116
|
-
|
117
|
-
fs.writeFileSync(root + Config.paths.output.root + "/importmap.json", JSON.stringify(importMap),'utf8');
|
118
|
-
resolve();
|
119
|
-
})
|
120
|
-
})
|
121
|
-
}
|
122
|
-
async cdn(type, inject) {
|
123
|
-
const replace = (await import('gulp-replace')).default;
|
124
|
-
const dir = root + Config.paths.cdn;
|
125
|
-
|
126
|
-
let cdnPaths = [];
|
127
|
-
let sri = {};
|
128
|
-
|
129
|
-
if (!fs.existsSync(root + Config.paths.cdn)){
|
130
|
-
fs.mkdirSync(root + Config.paths.cdn);
|
131
|
-
}
|
132
|
-
|
133
|
-
function spawnCmd(cmd) {
|
134
|
-
try {
|
135
|
-
return nodeCmd.execSync(cmd).toString();
|
136
|
-
}
|
137
|
-
catch (error) {
|
138
|
-
return error.output[1].toString()
|
139
|
-
}
|
140
|
-
}
|
141
|
-
|
142
|
-
const downloadFiles = async (url) => {
|
143
|
-
let urlName = url.lastIndexOf("/");
|
144
|
-
let fileName = url.substring(urlName + 1, url.length);
|
145
|
-
|
146
|
-
if (!fs.existsSync(root + Config.paths.cdn + "/" + fileName)) {
|
147
|
-
await Functions.download(url, dir + "/" + fileName);
|
148
|
-
}
|
149
|
-
|
150
|
-
if (Config.sri) {
|
151
|
-
sri[url] = `sha256-${spawnCmd(`cat ${root + Config.paths.cdn}/${fileName} | openssl dgst -sha256 -binary | openssl base64 -A`)}`;
|
152
|
-
}
|
153
|
-
|
154
|
-
cdnPaths.push(url.substring(0, urlName));
|
155
|
-
}
|
156
|
-
|
157
|
-
if (type === "templates") {
|
158
|
-
if (fs.existsSync(`${root + Config.paths.input.main}`)) {
|
159
|
-
const main = fs.readFileSync(root + Config.paths.input.main).toString();
|
160
|
-
|
161
|
-
if (typeof JSON.parse(main)["assets"] !== "undefined" && typeof JSON.parse(main)["assets"]["js"] !== "undefined") {
|
162
|
-
let urls = JSON.parse(main)["assets"]["js"];
|
163
|
-
let files = []
|
164
|
-
|
165
|
-
Object.keys(urls).forEach((name) => {
|
166
|
-
if (Array.isArray(urls[name])) {
|
167
|
-
urls[name].forEach(async (url) => {
|
168
|
-
if (url.includes("http")) {
|
169
|
-
files.push(downloadFiles(url))
|
170
|
-
}
|
171
|
-
})
|
172
|
-
} else {
|
173
|
-
if (urls[name].includes("http") && !urls[name].includes("?")) {
|
174
|
-
files.push(downloadFiles(urls[name]))
|
175
|
-
}
|
176
|
-
}
|
177
|
-
})
|
178
|
-
|
179
|
-
await Promise.all(files);
|
180
|
-
}
|
181
|
-
}
|
182
|
-
|
183
|
-
if (!fs.existsSync(root + Config.paths.output.root)) {
|
184
|
-
fs.mkdirSync(root + Config.paths.output.root);
|
185
|
-
}
|
186
|
-
|
187
|
-
fs.writeFileSync(`${root + Config.paths.output.root}/sri.json`, JSON.stringify(sri));
|
188
|
-
|
189
|
-
// TODO
|
190
|
-
if (inject === true) {
|
191
|
-
let task = gulp.src(root + Config.paths.output.root + '/*.html');
|
192
|
-
|
193
|
-
cdnPaths.forEach(function(rep) {
|
194
|
-
task = task.pipe(replace(rep, `/${Config.paths.cdn}`));
|
195
|
-
});
|
196
|
-
|
197
|
-
task.pipe(gulp.dest(root + Config.paths.output.root));
|
198
|
-
}
|
199
|
-
}
|
200
|
-
|
201
|
-
if (type === "scripts") {
|
202
|
-
if (fs.existsSync(`${root + Config.paths.input.scripts}/${Config.scripts.cdnPath}`)) {
|
203
|
-
const urls = fs.readFileSync(`${root + Config.paths.input.scripts}/${Config.scripts.cdnPath}`).toString().split(/\r?\n/g);
|
204
|
-
|
205
|
-
let files = []
|
206
|
-
|
207
|
-
Object.keys(urls).forEach(name => {
|
208
|
-
if (urls[name].includes("http") && !urls[name].includes("?")) {
|
209
|
-
let url = urls[name].match(/(?<=(["']\b))(?:(?=(\\?))\2.)*?(?=\1)/)[0];
|
210
|
-
|
211
|
-
cdnPaths.push(url);
|
212
|
-
files.push(downloadFiles(url));
|
213
|
-
}
|
214
|
-
});
|
215
|
-
|
216
|
-
await Promise.all(files);
|
217
|
-
}
|
218
|
-
|
219
|
-
if (fs.existsSync(`${root + Config.paths.output.root}/importmap.json`) && Config.scripts.importMap.localDownload) {
|
220
|
-
let importmap = JSON.parse(fs.readFileSync(`${root + Config.paths.output.root}/importmap.json`).toString());
|
221
|
-
let files = []
|
222
|
-
|
223
|
-
Object.keys(importmap["imports"]).map((name) => {
|
224
|
-
let filename = "esm." + name.replace(new RegExp("/", 'g'),"-") + ".js";
|
225
|
-
|
226
|
-
if (!fs.existsSync(root + Config.paths.cdn + "/" + filename) && name.slice(-1) !== "/") {
|
227
|
-
files.push(Functions.download(importmap["imports"][name], dir + "/" + filename));
|
228
|
-
importmap["imports"][name] = "/" + dir + "/" + filename;
|
229
|
-
}
|
230
|
-
});
|
231
|
-
|
232
|
-
await Promise.all(files);
|
233
|
-
|
234
|
-
if (fs.existsSync(dir + "/" + "importmap.json")) {
|
235
|
-
importmap = Object.assign(importmap, JSON.parse(fs.readFileSync(dir + "/" + "importmap.json").toString()));
|
236
|
-
}
|
237
|
-
|
238
|
-
fs.writeFileSync(dir + "/" + "importmap.json", JSON.stringify(importmap));
|
239
|
-
}
|
240
|
-
|
241
|
-
// TODO
|
242
|
-
if (inject === true) {
|
243
|
-
let task_js = gulp.src(root + Config.paths.output.scripts + "/" + JSON.parse(fs.readFileSync(root + Config.paths.output.scripts + "/rev-manifest.json", 'utf8').toString())["core.js"]);
|
244
|
-
|
245
|
-
cdnPaths.forEach(function (rep) {
|
246
|
-
task_js = task_js.pipe(replace(rep, "/" + root + Config.paths.cdn));
|
247
|
-
});
|
248
|
-
|
249
|
-
task_js.pipe(gulp.dest(root + Config.paths.output.scripts));
|
250
|
-
}
|
251
|
-
}
|
252
|
-
|
253
|
-
if (type === "styles") {
|
254
|
-
if (fs.existsSync(`${root + Config.paths.input.styles}/${Config.styles.vendor.path}`) && Config.styles.vendor.path.length !== 0) {
|
255
|
-
const urls = fs.readFileSync(`${root + Config.paths.input.styles}/${Config.styles.vendor.path}`).toString().split(/\r?\n/g);
|
256
|
-
|
257
|
-
let files = [];
|
258
|
-
|
259
|
-
Object.keys(urls).forEach(name => {
|
260
|
-
if (urls[name].includes("http")) {
|
261
|
-
files.push(downloadFiles(urls[name].substring(urls[name].indexOf("http"), urls[name].length - 2)))
|
262
|
-
}
|
263
|
-
})
|
264
|
-
|
265
|
-
await Promise.all(files)
|
266
|
-
}
|
267
|
-
}
|
268
|
-
}
|
269
|
-
postcssPlugins(config, after) {
|
270
|
-
let plugins = [postcssImport, tailwindcssNesting(postcssNesting({
|
271
|
-
noIsPseudoSelector: true
|
272
|
-
})), postcssCustomMedia, postcssCustomSelectors];
|
273
|
-
|
274
|
-
if (Exists.postcssConfig) {
|
275
|
-
return {config: root}
|
276
|
-
} else if (typeof config.extend !== "undefined") {
|
277
|
-
plugins = plugins.concat(config.extend)
|
278
|
-
} else if (Array.isArray(config) && config.length !== 0) {
|
279
|
-
return config;
|
280
|
-
}
|
281
|
-
|
282
|
-
return plugins.concat(after);
|
283
|
-
}
|
284
|
-
postcssPluginsEmails(config, after) {
|
285
|
-
let plugins = [postcssImport, postcssNesting({
|
286
|
-
noIsPseudoSelector: true
|
287
|
-
}), postcssCustomMedia, postcssCustomSelectors];
|
288
|
-
|
289
|
-
if (Exists.postcssConfig) {
|
290
|
-
return {config: root}
|
291
|
-
} else if (typeof config.extend !== "undefined") {
|
292
|
-
plugins = plugins.concat(config.extend)
|
293
|
-
} else if (Array.isArray(config) && config.length !== 0) {
|
294
|
-
return config;
|
295
|
-
}
|
296
|
-
|
297
|
-
return plugins.concat(after);
|
298
|
-
}
|
299
|
-
}
|
package/modules/Watch.js
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
import gulp from "gulp";
|
2
|
-
import {Config, Exists} from "./Core.js";
|
3
|
-
|
4
|
-
export class Watch {
|
5
|
-
get paths() {
|
6
|
-
return {
|
7
|
-
scripts: [`${Config.paths.input.scripts}/**`, `!${Config.paths.input.scripts}/**/\\${Config.scripts.importResolution.filename}`],
|
8
|
-
styles: [`${Config.paths.input.styles}/**`, `!${Config.paths.input.styles}/**/\\${Config.styles.importResolution.filename}`],
|
9
|
-
templates: [`${Config.paths.input.templates}/**`, Config.paths.input.main]
|
10
|
-
}
|
11
|
-
}
|
12
|
-
dev() {
|
13
|
-
if (!Config.vite) {
|
14
|
-
gulp.watch("package.json", Exists.templates ? gulp.series("importmap", "templates") : gulp.series("importmap"))
|
15
|
-
}
|
16
|
-
|
17
|
-
if (Exists.scripts) {
|
18
|
-
gulp.watch(this.paths.scripts, gulp.series("scripts"))
|
19
|
-
}
|
20
|
-
|
21
|
-
if (Exists.styles) {
|
22
|
-
gulp.watch(this.paths.styles, gulp.series("styles"))
|
23
|
-
}
|
24
|
-
|
25
|
-
if (Exists.templates) {
|
26
|
-
gulp.watch(this.paths.templates, gulp.series("templates"))
|
27
|
-
}
|
28
|
-
|
29
|
-
if (Exists.emails) {
|
30
|
-
gulp.watch(`${Config.paths.input.emails}/**`, gulp.series("emails"))
|
31
|
-
}
|
32
|
-
}
|
33
|
-
build(type) {
|
34
|
-
let templates = type !== "production" ? "templates" : "templates:production";
|
35
|
-
let assets = type !== "production" ? "assets" : "assets:production";
|
36
|
-
|
37
|
-
gulp.watch("package.json", Exists.templates ? gulp.series("importmap", templates) : gulp.series("importmap"))
|
38
|
-
|
39
|
-
if (Exists.scripts) {
|
40
|
-
let tasks = [`scripts:${type}`]
|
41
|
-
|
42
|
-
if (Exists.templates && Config.scripts.revision === true) {
|
43
|
-
tasks.push(templates)
|
44
|
-
}
|
45
|
-
|
46
|
-
gulp.watch(this.paths.scripts, gulp.series(tasks))
|
47
|
-
}
|
48
|
-
|
49
|
-
if (Exists.styles) {
|
50
|
-
let tasks = [`styles:${type}`]
|
51
|
-
|
52
|
-
if (Exists.templates && Config.styles.revision === true) {
|
53
|
-
tasks.push(templates)
|
54
|
-
}
|
55
|
-
|
56
|
-
gulp.watch(this.paths.styles, gulp.series(tasks))
|
57
|
-
}
|
58
|
-
|
59
|
-
if (Exists.templates) {
|
60
|
-
gulp.watch(this.paths.templates, gulp.series(templates))
|
61
|
-
}
|
62
|
-
|
63
|
-
if (Exists.icons && Exists.templates && Config.icons.revision === true) {
|
64
|
-
gulp.watch(`${Config.paths.output.icons}/${Config.icons.filename}*`, gulp.series(templates));
|
65
|
-
}
|
66
|
-
|
67
|
-
if (Exists.assets) {
|
68
|
-
gulp.watch(`${Config.paths.input.assets}/**`, gulp.series(assets))
|
69
|
-
}
|
70
|
-
|
71
|
-
if (Exists.emails) {
|
72
|
-
gulp.watch(`${Config.paths.input.emails}/**`, gulp.series("emails"))
|
73
|
-
}
|
74
|
-
}
|
75
|
-
}
|
@@ -1,84 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
4
|
-
|
5
|
-
const tailwindColors = (colors = []) => {
|
6
|
-
colors.forEach(name => {
|
7
|
-
colors[name] = ({ opacityValue }) => {
|
8
|
-
if (opacityValue === undefined) {
|
9
|
-
return `rgb(var(--color-${name}))`
|
10
|
-
}
|
11
|
-
return `rgb(var(--color-${name}) / ${opacityValue})`
|
12
|
-
};
|
13
|
-
});
|
14
|
-
|
15
|
-
return colors
|
16
|
-
};
|
17
|
-
|
18
|
-
const tailwindColorsRgba = (colors = []) => {
|
19
|
-
colors.forEach(name => {
|
20
|
-
colors[name] = ({opacityVariable, opacityValue}) => {
|
21
|
-
if (opacityValue !== undefined) {
|
22
|
-
return `rgba(var(--color-${name}), ${opacityValue})`
|
23
|
-
}
|
24
|
-
if (opacityVariable !== undefined) {
|
25
|
-
return `rgba(var(--color-${name}), var(${opacityVariable}, 1))`
|
26
|
-
}
|
27
|
-
return `rgb(var(--color-${name}))`
|
28
|
-
};
|
29
|
-
});
|
30
|
-
|
31
|
-
return colors
|
32
|
-
};
|
33
|
-
|
34
|
-
const tailwindColorsAccent = (colors = []) => {
|
35
|
-
const result = {};
|
36
|
-
|
37
|
-
colors.forEach(color => {
|
38
|
-
result[`.accent-${color}`] = {
|
39
|
-
'--color-accent': `var(--color-${color})`,
|
40
|
-
'accent-color': 'rgb(var(--color-accent))'
|
41
|
-
};
|
42
|
-
});
|
43
|
-
|
44
|
-
return result
|
45
|
-
};
|
46
|
-
|
47
|
-
const tailwindColorsCurrent = (colors = []) => {
|
48
|
-
const result = {};
|
49
|
-
|
50
|
-
colors.forEach(color => {
|
51
|
-
result[`.text-${color}`] = {
|
52
|
-
'--color-current': `var(--color-${color})`
|
53
|
-
};
|
54
|
-
});
|
55
|
-
|
56
|
-
return result
|
57
|
-
};
|
58
|
-
|
59
|
-
const tailwindVariables = (type, variables = [], values = {}) => {
|
60
|
-
variables.forEach(name => {
|
61
|
-
values[name] = `var(--${type}-${name})`;
|
62
|
-
});
|
63
|
-
|
64
|
-
return values
|
65
|
-
};
|
66
|
-
|
67
|
-
const tailwindAnimations = (values) => {
|
68
|
-
const result = {};
|
69
|
-
|
70
|
-
values.forEach(value => {
|
71
|
-
result[`.animation-${value}`] = {
|
72
|
-
'animation-name': value
|
73
|
-
};
|
74
|
-
});
|
75
|
-
|
76
|
-
return result
|
77
|
-
};
|
78
|
-
|
79
|
-
exports.tailwindAnimations = tailwindAnimations;
|
80
|
-
exports.tailwindColors = tailwindColors;
|
81
|
-
exports.tailwindColorsAccent = tailwindColorsAccent;
|
82
|
-
exports.tailwindColorsCurrent = tailwindColorsCurrent;
|
83
|
-
exports.tailwindColorsRgba = tailwindColorsRgba;
|
84
|
-
exports.tailwindVariables = tailwindVariables;
|
@@ -1,75 +0,0 @@
|
|
1
|
-
const tailwindColors = (colors = []) => {
|
2
|
-
colors.forEach(name => {
|
3
|
-
colors[name] = ({ opacityValue }) => {
|
4
|
-
if (opacityValue === undefined) {
|
5
|
-
return `rgb(var(--color-${name}))`
|
6
|
-
}
|
7
|
-
return `rgb(var(--color-${name}) / ${opacityValue})`
|
8
|
-
}
|
9
|
-
})
|
10
|
-
|
11
|
-
return colors
|
12
|
-
}
|
13
|
-
|
14
|
-
const tailwindColorsRgba = (colors = []) => {
|
15
|
-
colors.forEach(name => {
|
16
|
-
colors[name] = ({opacityVariable, opacityValue}) => {
|
17
|
-
if (opacityValue !== undefined) {
|
18
|
-
return `rgba(var(--color-${name}), ${opacityValue})`
|
19
|
-
}
|
20
|
-
if (opacityVariable !== undefined) {
|
21
|
-
return `rgba(var(--color-${name}), var(${opacityVariable}, 1))`
|
22
|
-
}
|
23
|
-
return `rgb(var(--color-${name}))`
|
24
|
-
}
|
25
|
-
})
|
26
|
-
|
27
|
-
return colors
|
28
|
-
}
|
29
|
-
|
30
|
-
const tailwindColorsAccent = (colors = []) => {
|
31
|
-
const result = {}
|
32
|
-
|
33
|
-
colors.forEach(color => {
|
34
|
-
result[`.accent-${color}`] = {
|
35
|
-
'--color-accent': `var(--color-${color})`,
|
36
|
-
'accent-color': 'rgb(var(--color-accent))'
|
37
|
-
}
|
38
|
-
})
|
39
|
-
|
40
|
-
return result
|
41
|
-
}
|
42
|
-
|
43
|
-
const tailwindColorsCurrent = (colors = []) => {
|
44
|
-
const result = {};
|
45
|
-
|
46
|
-
colors.forEach(color => {
|
47
|
-
result[`.text-${color}`] = {
|
48
|
-
'--color-current': `var(--color-${color})`
|
49
|
-
};
|
50
|
-
});
|
51
|
-
|
52
|
-
return result
|
53
|
-
};
|
54
|
-
|
55
|
-
const tailwindVariables = (type, variables = [], values = {}) => {
|
56
|
-
variables.forEach(name => {
|
57
|
-
values[name] = `var(--${type}-${name})`
|
58
|
-
})
|
59
|
-
|
60
|
-
return values
|
61
|
-
}
|
62
|
-
|
63
|
-
const tailwindAnimations = (values) => {
|
64
|
-
const result = {};
|
65
|
-
|
66
|
-
values.forEach(value => {
|
67
|
-
result[`.animation-${value}`] = {
|
68
|
-
'animation-name': value
|
69
|
-
};
|
70
|
-
});
|
71
|
-
|
72
|
-
return result
|
73
|
-
}
|
74
|
-
|
75
|
-
export { tailwindColors, tailwindVariables, tailwindColorsRgba, tailwindColorsAccent, tailwindColorsCurrent, tailwindAnimations }
|
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2019 scniro <scniro@outlook.com>
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -1,79 +0,0 @@
|
|
1
|
-
# gulp-clean-css
|
2
|
-
|
3
|
-
[![Build Status](https://img.shields.io/travis/scniro/gulp-clean-css.svg?style=flat-square)](https://travis-ci.org/scniro/gulp-clean-css)
|
4
|
-
[![Dependency Status](https://img.shields.io/david/scniro/gulp-clean-css.svg?label=deps&style=flat-square)](https://david-dm.org/scniro/gulp-clean-css)
|
5
|
-
[![devDependency Status](https://img.shields.io/david/dev/scniro/gulp-clean-css.svg?label=devDeps&style=flat-square)](https://david-dm.org/scniro/gulp-clean-css#info=devDependencies)
|
6
|
-
[![Coverage](https://img.shields.io/coveralls/scniro/gulp-clean-css.svg?style=flat-square)](https://coveralls.io/github/scniro/gulp-clean-css)
|
7
|
-
[![Downloads](https://img.shields.io/npm/dm/gulp-clean-css.svg?style=flat-square)](https://www.npmjs.com/package/gulp-clean-css)
|
8
|
-
[![NPM Version](https://img.shields.io/npm/v/gulp-clean-css.svg?style=flat-square)](https://www.npmjs.com/package/gulp-clean-css)
|
9
|
-
[![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/alferov/awesome-gulp#minification)
|
10
|
-
|
11
|
-
> [gulp](http://gulpjs.com/) plugin to minify CSS, using [clean-css](https://github.com/jakubpawlowicz/clean-css)
|
12
|
-
|
13
|
-
## Regarding Issues
|
14
|
-
|
15
|
-
This is just a simple [gulp](https://github.com/gulpjs/gulp) plugin, which means it's nothing more than a thin wrapper around `clean-css`. If it looks like you are having CSS related issues, please contact [clean-css](https://github.com/jakubpawlowicz/clean-css/issues). Only create a new issue if it looks like you're having a problem with the plugin itself.
|
16
|
-
|
17
|
-
## Install
|
18
|
-
|
19
|
-
```
|
20
|
-
npm install gulp-clean-css --save-dev
|
21
|
-
```
|
22
|
-
|
23
|
-
## API
|
24
|
-
|
25
|
-
### cleanCSS([*options*], [*callback*])
|
26
|
-
|
27
|
-
#### options
|
28
|
-
|
29
|
-
See the [`CleanCSS` options](https://github.com/jakubpawlowicz/clean-css#how-to-use-clean-css-api).
|
30
|
-
|
31
|
-
```javascript
|
32
|
-
const gulp = require('gulp');
|
33
|
-
const cleanCSS = require('gulp-clean-css');
|
34
|
-
|
35
|
-
gulp.task('minify-css', () => {
|
36
|
-
return gulp.src('styles/*.css')
|
37
|
-
.pipe(cleanCSS({compatibility: 'ie8'}))
|
38
|
-
.pipe(gulp.dest('dist'));
|
39
|
-
});
|
40
|
-
```
|
41
|
-
|
42
|
-
#### callback
|
43
|
-
|
44
|
-
Useful for returning details from the underlying [`minify()`](https://github.com/jakubpawlowicz/clean-css#using-api) call. An example use case could include logging `stats` of the minified file. In addition to the default object, `gulp-clean-css` provides the file `name` and `path` for further analysis.
|
45
|
-
|
46
|
-
```javascript
|
47
|
-
const gulp = require('gulp');
|
48
|
-
const cleanCSS = require('gulp-clean-css');
|
49
|
-
|
50
|
-
gulp.task('minify-css', () => {
|
51
|
-
return gulp.src('styles/*.css')
|
52
|
-
.pipe(cleanCSS({debug: true}, (details) => {
|
53
|
-
console.log(`${details.name}: ${details.stats.originalSize}`);
|
54
|
-
console.log(`${details.name}: ${details.stats.minifiedSize}`);
|
55
|
-
}))
|
56
|
-
.pipe(gulp.dest('dist'));
|
57
|
-
});
|
58
|
-
```
|
59
|
-
|
60
|
-
[Source Maps](http://www.html5rocks.com/tutorials/developertools/sourcemaps/) can be generated by using [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps).
|
61
|
-
|
62
|
-
```javascript
|
63
|
-
|
64
|
-
const gulp = require('gulp');
|
65
|
-
const cleanCSS = require('gulp-clean-css');
|
66
|
-
const sourcemaps = require('gulp-sourcemaps');
|
67
|
-
|
68
|
-
gulp.task('minify-css',() => {
|
69
|
-
return gulp.src('./src/*.css')
|
70
|
-
.pipe(sourcemaps.init())
|
71
|
-
.pipe(cleanCSS())
|
72
|
-
.pipe(sourcemaps.write())
|
73
|
-
.pipe(gulp.dest('dist'));
|
74
|
-
});
|
75
|
-
```
|
76
|
-
|
77
|
-
## License
|
78
|
-
|
79
|
-
[MIT](./LICENSE) © 2020 [scniro](https://github.com/scniro)
|