@newlogic-digital/core 0.8.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +4 -16
- package/modules/Core.js +3 -5
- package/modules/Serve.js +5 -2
- package/modules/Styles.js +4 -13
- package/modules/Utils.js +4 -1
- package/modules/tailwind/index.cjs +44 -0
- package/modules/tailwind/index.js +38 -0
- package/package.json +11 -10
package/index.js
CHANGED
@@ -15,27 +15,15 @@ import {
|
|
15
15
|
root
|
16
16
|
} from "./modules/Core.js";
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
const tailwindColors = (colors = []) => {
|
21
|
-
colors.forEach(name => {
|
22
|
-
colors[name] = ({opacityVariable, opacityValue}) => {
|
23
|
-
if (opacityValue !== undefined) {
|
24
|
-
return `rgba(var(--color-${name}), ${opacityValue})`
|
25
|
-
}
|
26
|
-
if (opacityVariable !== undefined) {
|
27
|
-
return `rgba(var(--color-${name}), var(${opacityVariable}, 1))`
|
28
|
-
}
|
29
|
-
return `rgb(var(--color-${name}))`
|
30
|
-
}
|
31
|
-
})
|
18
|
+
import { tailwindColors, tailwindColorsRgba, tailwindVariables } from './modules/tailwind/index.js'
|
32
19
|
|
33
|
-
|
34
|
-
}
|
20
|
+
const defineConfig = (config) => new Core().init(config);
|
35
21
|
|
36
22
|
export {
|
37
23
|
defineConfig,
|
38
24
|
tailwindColors,
|
25
|
+
tailwindVariables,
|
26
|
+
tailwindColorsRgba,
|
39
27
|
Core,
|
40
28
|
Utils,
|
41
29
|
Styles,
|
package/modules/Core.js
CHANGED
@@ -109,10 +109,7 @@ let Config = {
|
|
109
109
|
clean: {},
|
110
110
|
options: {},
|
111
111
|
nodeResolve: true,
|
112
|
-
nodeResolveIgnore: []
|
113
|
-
tailwind: {
|
114
|
-
keyframes: true
|
115
|
-
}
|
112
|
+
nodeResolveIgnore: []
|
116
113
|
},
|
117
114
|
vendor: {
|
118
115
|
cache: false,
|
@@ -126,6 +123,7 @@ let Config = {
|
|
126
123
|
import: ['all'],
|
127
124
|
themePath: "",
|
128
125
|
ratio: {
|
126
|
+
enabled: false,
|
129
127
|
content: [],
|
130
128
|
files: ["main.css"]
|
131
129
|
},
|
@@ -357,7 +355,7 @@ class Core {
|
|
357
355
|
}
|
358
356
|
}
|
359
357
|
|
360
|
-
if (Config.styles.ratio.content.length === 0 && Exists.templates) {
|
358
|
+
if (Config.styles.ratio.enabled && Config.styles.ratio.content.length === 0 && Exists.templates) {
|
361
359
|
Config.styles.ratio.content.push(`${root + Config.paths.input.templates}/**/*.{hbs,html,twig}`);
|
362
360
|
}
|
363
361
|
|
package/modules/Serve.js
CHANGED
@@ -52,7 +52,7 @@ export const Serve = new class {
|
|
52
52
|
}
|
53
53
|
|
54
54
|
let config = {
|
55
|
-
plugins: Config.serve.mode === "dev" ? [middleware, ratio, reload] : [middleware, reload],
|
55
|
+
plugins: (Config.serve.mode === "dev" && Config.styles.ratio.enabled) ? [middleware, ratio, reload] : [middleware, reload],
|
56
56
|
publicDir: `${Config.paths.output.root}`,
|
57
57
|
server: {
|
58
58
|
open: Config.serve.index,
|
@@ -106,7 +106,10 @@ export const Serve = new class {
|
|
106
106
|
await this.server.listen()
|
107
107
|
|
108
108
|
console.log(chalk.cyan(`\n vite v${require('vite/package.json').version}`) + chalk.green(` dev server running at:\n`))
|
109
|
-
|
109
|
+
|
110
|
+
this.server.printUrls()
|
111
|
+
|
112
|
+
console.log(" ");
|
110
113
|
|
111
114
|
resolve();
|
112
115
|
})
|
package/modules/Styles.js
CHANGED
@@ -122,7 +122,9 @@ export class Styles {
|
|
122
122
|
findPaths(items, `${root + Config.paths.input.styles}/${directory}`);
|
123
123
|
});
|
124
124
|
|
125
|
-
|
125
|
+
if (Config.styles.ratio.enabled) {
|
126
|
+
fs.writeFileSync(`${root + Config.paths.temp}/ratio.css`, new Styles().ratio(Config.styles.ratio.content))
|
127
|
+
}
|
126
128
|
|
127
129
|
resolve();
|
128
130
|
})
|
@@ -151,16 +153,6 @@ export class Styles {
|
|
151
153
|
}
|
152
154
|
});
|
153
155
|
|
154
|
-
const purge = lazypipe().pipe(purgeCSS, Object.assign({
|
155
|
-
content: Config.styles.purge.content,
|
156
|
-
extractors: [
|
157
|
-
{
|
158
|
-
extractor: content => content.match(/[^<>"'`\s]*[^<>"'`\s:]/g) || [],
|
159
|
-
extensions: ['html', 'js', 'hbs', 'tpl', 'latte', 'twig']
|
160
|
-
}
|
161
|
-
]
|
162
|
-
}, Config.styles.purge.tailwind));
|
163
|
-
|
164
156
|
let tailwindcssConfig = {};
|
165
157
|
|
166
158
|
if (!Exists.tailwindConfig) {
|
@@ -169,7 +161,6 @@ export class Styles {
|
|
169
161
|
|
170
162
|
gulp.src(`${root + Config.paths.input.styles}/${Config.styles.tailwind.basename}`)
|
171
163
|
.pipe(postcss(new Utils().postcssPlugins(Config.styles.tailwind.postcss, [tailwindcss(tailwindcssConfig), autoprefixer])))
|
172
|
-
.pipe(gulpif(Config.styles.purge.enabled, purge()))
|
173
164
|
.pipe(gulpif(Config.styles.optimizations, clean()))
|
174
165
|
.pipe(gulp.dest(root + Config.paths.temp))
|
175
166
|
.on("end", resolve)
|
@@ -286,7 +277,7 @@ export class Styles {
|
|
286
277
|
return new Promise(resolve => {
|
287
278
|
gulp.src([`${root + Config.paths.input.styles}/*.{css,less}`, `!${root + Config.paths.input.styles}/${Config.styles.tailwind.basename}`, `!${root + Config.paths.input.styles}/*-modifiers.less`])
|
288
279
|
.pipe(plumber(Functions.plumber))
|
289
|
-
.pipe(ratio(Config.styles.ratio.content))
|
280
|
+
.pipe(gulpif(Config.styles.ratio.enabled, ratio(Config.styles.ratio.content)))
|
290
281
|
.pipe(vendor())
|
291
282
|
.pipe(build())
|
292
283
|
.pipe(Functions.revRewriteOutput())
|
package/modules/Utils.js
CHANGED
@@ -6,6 +6,7 @@ import postcssImport from "postcss-import";
|
|
6
6
|
import postcssNesting from "postcss-nesting";
|
7
7
|
import postcssCustomMedia from "postcss-custom-media";
|
8
8
|
import postcssCustomSelectors from "postcss-custom-selectors";
|
9
|
+
import tailwindcssNesting from "tailwindcss/nesting/index.js";
|
9
10
|
import {Config, Exists, Functions, root} from "./Core.js";
|
10
11
|
|
11
12
|
export class Utils {
|
@@ -266,7 +267,9 @@ export class Utils {
|
|
266
267
|
}
|
267
268
|
}
|
268
269
|
postcssPlugins(config, after) {
|
269
|
-
let plugins = [postcssImport, postcssNesting
|
270
|
+
let plugins = [postcssImport, tailwindcssNesting(postcssNesting({
|
271
|
+
noIsPseudoSelector: true
|
272
|
+
})), postcssCustomMedia, postcssCustomSelectors];
|
270
273
|
|
271
274
|
if (Exists.postcssConfig) {
|
272
275
|
return {config: root}
|
@@ -0,0 +1,44 @@
|
|
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 tailwindVariables = (type, variables = [], values = {}) => {
|
35
|
+
variables.forEach(name => {
|
36
|
+
values[name] = `var(--${type}-${name})`;
|
37
|
+
});
|
38
|
+
|
39
|
+
return values
|
40
|
+
};
|
41
|
+
|
42
|
+
exports.tailwindColors = tailwindColors;
|
43
|
+
exports.tailwindColorsRgba = tailwindColorsRgba;
|
44
|
+
exports.tailwindVariables = tailwindVariables;
|
@@ -0,0 +1,38 @@
|
|
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 tailwindVariables = (type, variables = [], values = {}) => {
|
31
|
+
variables.forEach(name => {
|
32
|
+
values[name] = `var(--${type}-${name})`
|
33
|
+
})
|
34
|
+
|
35
|
+
return values
|
36
|
+
}
|
37
|
+
|
38
|
+
export { tailwindColors, tailwindVariables, tailwindColorsRgba }
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@newlogic-digital/core",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.
|
4
|
+
"version": "0.9.1",
|
5
5
|
"main": "index.js",
|
6
6
|
"author": "New Logic Studio s.r.o.",
|
7
7
|
"description": "Set of tools that can be used to create modern web applications",
|
@@ -9,11 +9,12 @@
|
|
9
9
|
"scripts": {
|
10
10
|
"docs:dev": "vitepress dev docs",
|
11
11
|
"docs:build": "vitepress build docs",
|
12
|
-
"docs:serve": "vitepress serve docs"
|
12
|
+
"docs:serve": "vitepress serve docs",
|
13
|
+
"tailwind": "rollup modules/tailwind/index.js --file modules/tailwind/index.cjs --format cjs"
|
13
14
|
},
|
14
15
|
"dependencies": {
|
15
|
-
"@babel/core": "^7.16.
|
16
|
-
"@babel/preset-env": "^7.16.
|
16
|
+
"@babel/core": "^7.16.12",
|
17
|
+
"@babel/preset-env": "^7.16.11",
|
17
18
|
"@rollup/plugin-babel": "^5.3.0",
|
18
19
|
"@rollup/plugin-commonjs": "^21.0.1",
|
19
20
|
"@rollup/plugin-node-resolve": "^13.1.3",
|
@@ -39,22 +40,22 @@
|
|
39
40
|
"lazypipe": "^1.0.2",
|
40
41
|
"lodash": "^4.17.21",
|
41
42
|
"postcss-custom-media": "^8.0.0",
|
42
|
-
"postcss-custom-properties": "^12.
|
43
|
+
"postcss-custom-properties": "^12.1.3",
|
43
44
|
"postcss-custom-selectors": "^6.0.0",
|
44
45
|
"postcss-import": "^14.0.2",
|
45
|
-
"postcss-nesting": "^
|
46
|
-
"rollup": "^2.
|
46
|
+
"postcss-nesting": "^10.1.2",
|
47
|
+
"rollup": "^2.66.1",
|
47
48
|
"rollup-plugin-import-map": "^2.2.2",
|
48
49
|
"rollup-plugin-terser": "^7.0.2",
|
49
|
-
"vite": "~2.7.
|
50
|
+
"vite": "~2.7.13"
|
50
51
|
},
|
51
52
|
"peerDependencies": {
|
52
53
|
"autoprefixer": "^10.4.2",
|
53
54
|
"postcss": "^8.4.5",
|
54
|
-
"tailwindcss": "^
|
55
|
+
"tailwindcss": "^3.0.16"
|
55
56
|
},
|
56
57
|
"devDependencies": {
|
57
|
-
"vitepress": "^0.
|
58
|
+
"vitepress": "^0.21.6"
|
58
59
|
},
|
59
60
|
"files": [
|
60
61
|
"index.js",
|