@newlogic-digital/core 0.7.5 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +3 -16
- package/modules/Core.js +3 -5
- package/modules/Serve.js +8 -2
- package/modules/Styles.js +4 -13
- package/modules/Utils.js +4 -1
- package/modules/tailwind/index.cjs +27 -0
- package/modules/tailwind/index.js +22 -0
- package/package.json +16 -15
package/index.js
CHANGED
@@ -15,27 +15,14 @@ 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, 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,
|
39
26
|
Core,
|
40
27
|
Utils,
|
41
28
|
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,
|
@@ -60,6 +60,9 @@ export const Serve = new class {
|
|
60
60
|
fsServe: {
|
61
61
|
strict: false
|
62
62
|
},
|
63
|
+
hmr: {
|
64
|
+
host: 'localhost'
|
65
|
+
},
|
63
66
|
watch: {
|
64
67
|
ignored: ['**/node_modules/**', '**/.git/**', '**/src/templates/**', '**/src/main.json', `**/${Config.paths.output.root}/*.html`]
|
65
68
|
}
|
@@ -103,7 +106,10 @@ export const Serve = new class {
|
|
103
106
|
await this.server.listen()
|
104
107
|
|
105
108
|
console.log(chalk.cyan(`\n vite v${require('vite/package.json').version}`) + chalk.green(` dev server running at:\n`))
|
106
|
-
|
109
|
+
|
110
|
+
this.server.printUrls()
|
111
|
+
|
112
|
+
console.log(" ");
|
107
113
|
|
108
114
|
resolve();
|
109
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,27 @@
|
|
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 tailwindVariables = (type, variables = [], values = {}) => {
|
19
|
+
variables.forEach(name => {
|
20
|
+
values[name] = `var(--${type}-${name})`;
|
21
|
+
});
|
22
|
+
|
23
|
+
return values
|
24
|
+
};
|
25
|
+
|
26
|
+
exports.tailwindColors = tailwindColors;
|
27
|
+
exports.tailwindVariables = tailwindVariables;
|
@@ -0,0 +1,22 @@
|
|
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 tailwindVariables = (type, variables = [], values = {}) => {
|
15
|
+
variables.forEach(name => {
|
16
|
+
values[name] = `var(--${type}-${name})`
|
17
|
+
})
|
18
|
+
|
19
|
+
return values
|
20
|
+
}
|
21
|
+
|
22
|
+
export { tailwindColors, tailwindVariables }
|
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.0",
|
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,15 +9,16 @@
|
|
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
|
-
"@babel/preset-env": "^7.
|
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
|
-
"@rollup/plugin-node-resolve": "^13.
|
20
|
-
"@rollup/plugin-replace": "^3.0.
|
20
|
+
"@rollup/plugin-node-resolve": "^13.1.3",
|
21
|
+
"@rollup/plugin-replace": "^3.0.1",
|
21
22
|
"adm-zip": "^0.5.9",
|
22
23
|
"clean-css": "^5.2.2",
|
23
24
|
"fs-extra": "^10.0.0",
|
@@ -31,7 +32,7 @@
|
|
31
32
|
"gulp-inline-css": "^4.0.0",
|
32
33
|
"gulp-plumber": "^1.2.1",
|
33
34
|
"gulp-postcss": "^9.0.1",
|
34
|
-
"gulp-purgecss": "^4.
|
35
|
+
"gulp-purgecss": "^4.1.3",
|
35
36
|
"gulp-rename": "^2.0.0",
|
36
37
|
"gulp-replace": "^1.1.3",
|
37
38
|
"gulp-rev": "^9.0.0",
|
@@ -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.
|
50
|
+
"vite": "~2.7.13"
|
50
51
|
},
|
51
52
|
"peerDependencies": {
|
52
|
-
"autoprefixer": "^10.4.
|
53
|
-
"postcss": "^8.
|
54
|
-
"tailwindcss": "^
|
53
|
+
"autoprefixer": "^10.4.2",
|
54
|
+
"postcss": "^8.4.5",
|
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",
|